From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194791; cv=none; d=zohomail.com; s=zohoarc; b=AHOpQFB/ed5ysNZPoHhKq2vZH9lgjQvPtRwb4N1Ja8aULkNj7LTZgF86nX6Kkn71pLz5LSIBL9zZVupRUtcyEGcvg61KsaMQsY5YjbaCD6w43bbQBtc+0+8/TW+jgEsQgun/8IUXfKraMNMDabFhjot7rXVRD+qZpYKbosCvjNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194791; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VLr+xD3lcIgvVVDil2eTvpXN1BKFT2tB+eVaYQx5foI=; b=lhi3WCikp7J8JtYC/hLXeWcd695ffg7+J1tw1it/P+PNETcu7d+BuAf/KeA3+3sr2OpZpOBL2UPHEBXczJzzL4/gF6gY6xl0R9o2IQvUm3q/sznqUTb8UBJ1jKJD+vZX67r0oL75RsN1Y6kuoXFf20KaqD3BB3LiO8FAFp6+nBc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194791407899.7119701464693; Fri, 20 Nov 2026 09:13:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSAS-0002uo-Sd; Fri, 20 Nov 2026 12:12:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAN-0002rV-Ek for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:12:51 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAL-0002ia-IV for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:12:51 -0500 Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfii52947046 for ; Fri, 20 Nov 2026 17:12:47 GMT Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjjaw57-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:12:47 +0000 (GMT) Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-5eacd2f2229so1019590e0c.0 for ; Fri, 20 Nov 2026 09:12:47 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884c3063sm103835075e9.15.2026.11.20.09.12.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= VLr+xD3lcIgvVVDil2eTvpXN1BKFT2tB+eVaYQx5foI=; b=F+pEWLGQfaFOXAB/ WuPw4D+mqdD+izdWAgVW/8vQ52KVxT/xjTmaZQYlFTED67mStxsDMF4LuKs6Aj6A /3/W/kIam0LStdyQS3dWYbAgoB4GKhqASvuoqtDtajNKwL8ddUGfPFJC9/ul+bul WNsGacHhzrBOCho7ayZBTkd7lwPAFQZd3The4sbbje5JjjS2wenHhjImfpyqNcox GPLVSeY2HAJMI4xafQhK8y5wnmbRpxbTKR7iYGTT2WkSoVkcumUtYOjgSYHY/rYH ce67m+cCIN5VO/hJcziez697EVNsHbcNfCO0jLKMOodRhyQlpuS8JcIFprFouWAH Mhkiew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194766; x=1795799566; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=VLr+xD3lcIgvVVDil2eTvpXN1BKFT2tB+eVaYQx5foI=; b=Uc+zviXT9XwU9MARa6+IcSF0hJttMTtm/3w75FkmarVM4ipt4pP0zWZl5lrrqVBQ9b GcIeqc72BWqfOvPLzI8tNfpd/D2EcUKBkp4AkK34i+dDYHap2ss0vvfWmsXAo+O/Q+3Z 6/saLx2ZQADqdYyYlgx+6bdkeFk5SXR0GPaD8yF/uZSbphV6dygVFLiP5l/UA0jC8fvm Kpmw20Lz/AHhfDeZJLU3mvyBgL22Z9dCnekkQFtk6cXtW0tZPeKXTdatqeDtJhEOj12c lnROKuMC3ijF79cDkR1uCbDZZplcabsDgUIqUKjeU3bwm8jxAauTUFGS1SFjSuxDW6OG rtIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194766; x=1795799566; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VLr+xD3lcIgvVVDil2eTvpXN1BKFT2tB+eVaYQx5foI=; b=jsUhlFPvB7Nbo4mTu65x/D0/0prjGzIHbx0FgqX9kuCps0jd2SpQJQosfeXMlahF49 WZPlcnNPJpQZsDkHvEyhwPQA3sJhQ1BHQMkEzvZzlVHGiJQm6KLIkkWjr7Y8wOkVeWFN +TIStqUgfEzgVdZJ0uL8Gt6DMLaXTr31XfF+kP87+7LQTtzw/rhO+XxVDUKkc6So2VVI wAzvlNaWwPRW/zb8xLZLopOgJiC/xtTbKn6TOt5cZ2sW40AVBELakgywiYYN+jglVzqE oIVx29nxWE1RFz0aekyLxjzEJYfdeacFgPL3Yreg4C7HsjwtGA+DYKpgQmhRahdf18Hq hbTQ== X-Gm-Message-State: APuU4Z8ieQ+DiuEMcyoJ7AUuUy3A29QuAs0XHD6jnm786uVi1F0bLVY2 RZiU962DFuhKPb8RURkM110GYMqvZlbKK2g9QThXIP/XrLmxD4auu4HkWI/4iiOKbOs9xY8edJN Yr2QsfY5bjG3MDoPFnu1XDVkNSRr6YLrup+7CiEM8f3nWKED19pfrCN0LJGNYGCgtVA== X-Gm-Gg: AZFdTZfjrbNIKvnlIZCQZwkVh2QKX/WTA+rOrFRYSJq34iOXA/msEMPlF+2XqP7hK02 /eufLrY1Nm/5G6NN0NRBL5jpIWHwwGG1JXh0ZZL87K12OCRnKy1gRYXkiApTQ50QYipB1IyMGYa OmHQ40y+X+jzjRlQyDyeE596KNGFjn/kUSIk0Ce3KCPK0CC7h89itvke1DmL5juQvlzPXwlfiYi /4t5je/88VIs8DCT5EFUyphbSuES9QvG5qsKVwPCNaab6/OSjUrXl4KAB3G3Gn4OG3hhI4S2WiF 4vLvOtIq/sVmAVRnERVh7YrhcJFPrapm8fHi8cAtm22xbSBSAcsA2cKgvLNDzU5GgC1WQk9FjMz hGl/ZXEJ6nuRJj0rABp9Y2FzVWzX2wGcesoFBMCAxewLSzGVsM2kccag3omhsW1V00nIsJXsRVS v8TtIHm0PDtJCLYA== X-Received: by 2002:a05:6122:32c6:b0:5ec:c180:e1a1 with SMTP id 71dfb90a1353d-5ee8adf3300mr2539583e0c.2.1795194765766; Fri, 20 Nov 2026 09:12:45 -0800 (PST) X-Received: by 2002:a05:6122:32c6:b0:5ec:c180:e1a1 with SMTP id 71dfb90a1353d-5ee8adf3300mr2539564e0c.2.1795194765296; Fri, 20 Nov 2026 09:12:45 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2 v4 01/14] hw/scsi/ncr53c710: Cancel the in-flight request on soft reset Date: Fri, 20 Nov 2026 18:12:21 +0100 Message-ID: <20261120171235.61325-2-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=FJaOVOos c=1 sm=1 tr=0 ts=6b007f8f cx=c_pps a=JIY1xp/sjQ9K5JH4t62bdg==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=evIlfggg4VWQIB3UXMIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=tNoRWFLymzeba-QzToBc:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX5930hcYynTKy wcJ2tgBsWN3qRNmK8eqcLoDRoRCve/2HAKp+zn9yW6cytnkC5ywf+yj8cF/b7w0S1Rvg81vsRw0 wUNmX3s74subLbrznYwem28bBOMHm/Q= X-Proofpoint-ORIG-GUID: s8ZX3lbHwD0z0RSaviNGxTzw5nMxcEnM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX3BVjwtfQCIYv Lq26TD1fWQJGe5gGb+u8t2nQa11Aq5QIYPezBnx+Y0EoTplcp6iptawFqaOmH3ts58/qZtOKu8s 91wQWwneA6sibD97mfbKlJJ4Yqn4J2jM2Hh0FlqvRjqfLuY9nlEa1YUgZWwD1scn165khEGoB84 Fryu7y3LNrY8I/8oY7Fj9uz/ZKg1pwa3kzmFG1dSSmQtXDAfKhzKu4Ke32HlmbsNsK0qG5MeZXP eIkff4GzXpYKMPCkJ1S4oBQZyOCwB8M9vuTnNphRpqXUORJMph00a/uGQLcRj+UiG5EeGfIEGrO Zy+CIWrAU2bJga+xVcOXhD+/YxWWsz4yFH3M5O2U88EcyLQT2hOp06ZFHdx951KlCXPFcWB53Et VD8ICzTFgjtYgkxwJRIQvxFaLGqkKW9B7xMCg6pDLlxx4+4nIZKE+atbPiFTK8jgnR3BjM+20lo FIYH+zFnKPntJu45DVA== X-Proofpoint-GUID: s8ZX3lbHwD0z0RSaviNGxTzw5nMxcEnM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194793820158500 ncr710_soft_reset() drops s->current and clears the request's hba_private without telling the SCSI layer. The request stays queued on the device and, once it completes or asks for data, the HBA callbacks find a NULL hba_private (ncr710_transfer_data() asserts on it). Cancel the request first. scsi_req_cancel() invokes ncr710_request_cancelled(), which releases the NCR710Request and the HBA's reference on the request; ncr710_clear_pending_irq() then finds s->current already NULL and has nothing left to do. If the request is not enqueued, scsi_req_cancel() does nothing and the previous behaviour is kept. AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 57967e7a84f0..10daa66e840d 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -364,6 +364,10 @@ void ncr710_soft_reset(NCR710State *s) s->sidl =3D 0; s->sfbr =3D 0; qemu_set_irq(s->irq, 0); + if (s->current && s->current->req) { + /* Drops hba_private via ncr710_request_cancelled() */ + scsi_req_cancel(s->current->req); + } ncr710_clear_pending_irq(s); ncr710_scsi_fifo_init(&s->scsi_fifo); } --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194800; cv=none; d=zohomail.com; s=zohoarc; b=DH3TN85afxzmCAZkBzM8kc5VzI3nFCYdH6AZDNpAlyB7cIJnZWwrgwLidiv1qwA8Esr7WnHqZD/R5Uv4XGOAr1JHKUwymmyddd0G2UpSNOJqnjju417CDP43bpW5dNz0GNoAbro1qnW6xSSuloUQytEV7e6REdl5D6d5Ke3lynE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194800; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H94EjNre9w4NR30/2zQfRAkYfSeNl9NtNJ0rW1z9QRw=; b=UG/CBdy0ii/Oc+oIpb+fYuFh2E5fIZhhZFwP20njOYHMuG3LKEYSBewKqzzcG6X8zSRAR8EmURH3Tdc2QECMZyQczldikUBglBkMUI+oYWEVejgbcWtNfZulp1QF3TxToW3+MKy22lVVPZitFRYuKYRfPGIyzwl8xkSjjq81k+M= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194800722301.9044623100183; Fri, 20 Nov 2026 09:13:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSAk-0002yA-10; Fri, 20 Nov 2026 12:13:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAT-0002vh-V0 for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:12:58 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAS-0003CQ-3J for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:12:57 -0500 Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEffUo2946995 for ; Fri, 20 Nov 2026 17:12:54 GMT Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjjaw5s-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:12:54 +0000 (GMT) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-94961ed97d6so197315485a.1 for ; Fri, 20 Nov 2026 09:12:54 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb9067846esm474755e9.4.2026.11.20.09.12.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:12:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= H94EjNre9w4NR30/2zQfRAkYfSeNl9NtNJ0rW1z9QRw=; b=aMzuOi1zBbC9GTDF uGCWiw83hJUUPxVg19nkkVU6RKYEjgp94wwmhFjhfo27f1kGd0u6Ngaj5Wu1+a1n 2fLZfrALxhDniHNfimvQYht9qF9rxZboydf5LsB5e+0jf4TJLe+4gUok7/KOvodO c1YVTqsJ8LcgikmpW1YyBRyONgGge59LMlLLARtHHLrZELDKAXN37giMyjmjUdIJ eyrqwHD2FmuBAQqwkoVAoQIH2HRgzMYR2m+yo9ojFcHE4rZDRlYgrSX/VwmT62++ 4YV2uxsztXaojR02cxrAfMks3aenVCxS4ETJUxnk9Hxn3vLqzbQwMl9+rsZ5+uve oa/jIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194773; x=1795799573; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=H94EjNre9w4NR30/2zQfRAkYfSeNl9NtNJ0rW1z9QRw=; b=S2wgDLRxYVPJw5tRZx6y3cxZsUdDLSvJFlD1V+TzKlHpWJfixVtdeoPeSu4YmCWxLy Bw8VFIoiEN2fTGB9BAXina7aelLguWzPeWkhBabRtgkeubgOdLLlmuWPXRP8RwvU6m3M Wm1GEOZNP0jncYDshpGkKobvAGR9u/cZXl56BGSOoKJmHWwTx+VsdOHDVJWUBT4bf4zO S4tmn9M4n+eumIbJQt9UmBJC34rxf02DALKkZxxsPZNPbpD4O4fad1VFDTFp1D056y8J ypfrLNcnlUMypA7knQykE+3cWOpdHlieyqoHFr2RsmRzGcfY7Ydmjb0SaZ3t1u4k5y/I PTpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194773; x=1795799573; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=H94EjNre9w4NR30/2zQfRAkYfSeNl9NtNJ0rW1z9QRw=; b=B7v2Uoe/lKRfodMMlSetxxv8wvfPQhdkEWWUfkMAxMkb4FpUBnLequExrIS7AkWo/8 mUQ+icbHQ/PsY0YINvAeTZD64lt0wmHqHkY1ZExlnNmHQWxn+IEWuTDOmTWD4DzUyNMQ CiJuQ2aoRjH4/AiAjcs99lS9i11K/BQElYM77wNUfVYdUjIAdzGbg1vOnrbZeh0N1EKO DNzLpnx6Xq5oaoBFr2/sUaCJ8j8gIPN7DJ75ywkFgNAbWwLXiXZJ+LVI8Ad0OcEHJFxk mELqwfk05AohKcZpE8li2YPUD1oqwG99RR3QZwMf55zeVotmmyRcAPxc4Na5eAurNoqe 73gw== X-Gm-Message-State: APuU4Z8xFK1ps3t7YnnP8oDuX1fLz0X2oMBPMkRYLpT8QryTu0HVkmeK EBqmdqwPj3WunrHijpYMZawjU8d5k9t+cOJEAZ3yFvWaJkXhewaQlMOqeepjuBUdoCO5kkYIW8I sGA3dKHEPyMhmjLorLQCdo5oa54UnMGYFady0gNWPtbzb7uehu5f+F8CfOcalBTt03A== X-Gm-Gg: AYBFou1TsTgUM4DAt9jRnBcoCtDpUfHVbv1vO87ww9l4AmPBJBz/PiLJsewPITqoHQQ tvndCsjWQTbh5+8/Lk/CrbGzvj71tHKdMjZWza2/bdFam7wMW2BnisoA5s5/UFZo+U9PWrkmu1n X8g/gw4M6PXJn7rGRHc57XGwylo+XfvIT7mPqfEgundeqS0PDLCOoV3wROdmOfZLtJguNWGcoOV V66TvtH2Bb4OSYnuD8DAVmKkkKoEa9QdrSMG8gdADJrx3AlXFIhYyw4guMJoQ+ClellTi7ipn4b p8tE9qtJv2xOEtihrKyHKSrLV0e/4enezC0lh1bPmxpUJmyr3j9PUjRxn+JydUd6+JJwISLDt9R zh/x092WG1vVJmizE82niA9QXad7JCMEX/G2PpPLRh1et2bwMbzwxkIPhQLJ6j13PKGal0WSB/9 lnSz4yfX8WuRKJRQ== X-Received: by 2002:a05:620a:6401:b0:93f:2571:c317 with SMTP id af79cd13be357-949b36030b2mr796091685a.28.1795194772708; Fri, 20 Nov 2026 09:12:52 -0800 (PST) X-Received: by 2002:a05:620a:6401:b0:93f:2571:c317 with SMTP id af79cd13be357-949b36030b2mr796088085a.28.1795194772314; Fri, 20 Nov 2026 09:12:52 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2 v4 02/14] hw/scsi/ncr53c710: Do not load SBCL from DBC after a SCRIPTS phase move Date: Fri, 20 Nov 2026 18:12:22 +0100 Message-ID: <20261120171235.61325-3-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=FJaOVOos c=1 sm=1 tr=0 ts=6b007f96 cx=c_pps a=HLyN3IcIa5EE8TELMZ618Q==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=sMRSD98Anrl0H7Wvm04A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=bTQJ7kPSJx9SKPbeHEYW:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXygLa60pVpwcc HG3Z3aunlNraYah6kzLah+Zy5SttvYFImzyGda3Xhg1Pw3lqYG8wqermgXUz9/OJSA4GdpOqYNo AlVs4nqhscYvRJ9HZGxWc0Ws8xbL/X4= X-Proofpoint-ORIG-GUID: BX3PSd2QpLC0pAJ-stzxr-Cq5HCplx0G X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX8iw/iPGnYml7 Jl6nVjR/gb8FxewSGHvH8nidsQo+vAmqvxehvI4j4vNtbZXhRkUYe82lPpeQVFmNZPzCdj9iIcJ hH7eCec/7lxt7e0IJ7lOAY2H1YjQwUf4WKw/U/EA9y6CgrZT6wt4lqCRDHBPk/6DzyUOTIC3yKc gDfA0PvJcRBXdwkRYudp1Qi+uAAWuih+kYX/nU2hG11ScQtjcEMaK7Wv6LBz6Q8CM0wCnBKp6gC QF+oGaPS6zo8XCHC1P4YTtul9OrcUCDzQHXbAKrZtB4X2qXSUyWiY5+hWq8jvGz77g/P8Xf21NF tvnZFySMKdv90JLuwcPDCmuF6X+WJvIihROGZr2Avs5r+xp6oeUz2MLMJVvcCuKUjfEEPMAPfoR Db/1GzvmhTFRKRH9f+NPfm/OXN5CknPe5BS42CA0v8NC3AT30/yxBTKyNZ8KnLjzsr2eHUc7YnD YaqP+/U34kw6axM82Nw== X-Proofpoint-GUID: BX3PSd2QpLC0pAJ-stzxr-Cq5HCplx0G X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194801828158500 After a SCRIPTS Block Move, ncr710_execute_script() copies DBC, the transfer byte count, into SBCL. SBCL (SCSI Bus Control Lines) mirrors the state of the SCSI bus control signals, it is not a byte counter, so this overwrites it with unrelated data. The preceding line already updates CTEST5 from the DBC bits that the chip exposes there. Remove the assignment. The effect on guests is inferred from the register definition; it has not been reproduced with a failing guest. AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 10daa66e840d..9ea2c47744e7 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -1400,7 +1400,6 @@ again: BADF("Unimplemented phase %d\n", s->sstat2 & PHASE_MASK); } s->ctest5 =3D (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3); - s->sbcl =3D s->dbc; break; =20 case 1: /* IO or Read/Write instruction. */ --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194865; cv=none; d=zohomail.com; s=zohoarc; b=SQMe8A7+UPhI2HxnOkywVZ5VGxMVcXjaLAh2PLAMi2BMJWUoK8VOLt4anrfn41xPsIEDHhR0hV1xRAB5VSQxtmJBEIPNTpbAfPG6zCnuJROXhyw5Hd0ZR3J+OSYQDz4Z9pJthhtf/vUPxvB1hO56lkUs3Aqtt/DMBmu2j9+USYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194865; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/7s8ABkw8A0jDP5RoPLduBdGQ6lnCYdbqKkIWsykgw0=; b=aPC+GW/+Jw7K75s56rsBq0XEhVQiQF3IneXtFV8+D/t6kuMVu914spI1wXXLGZa0Pw9d/E8CFq+dytRsgGuNP2GcgdhTwOrxZhbwAyLBnVKrP4xXiZIDV2tr/4fecjWosgT/+BWUc7XiyajXptd3jzvfK1MSblIZBYEtyoxpMnU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194865118419.6222926067028; Fri, 20 Nov 2026 09:14:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBG-0003HK-86; Fri, 20 Nov 2026 12:13:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAc-0002xn-8Z for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:08 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAZ-0003iS-09 for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:06 -0500 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfNct2196365 for ; Fri, 20 Nov 2026 17:13:01 GMT Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2cd1uk9v-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:01 +0000 (GMT) Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-9211604468aso17909256d6.3 for ; Fri, 20 Nov 2026 09:13:01 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8d4f9aa8sm48714965e9.4.2026.11.20.09.12.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:12:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= /7s8ABkw8A0jDP5RoPLduBdGQ6lnCYdbqKkIWsykgw0=; b=ao1QSem9XZy5ORgA QhxEeTyfnTKJ5pSXQDF+Pib7rQTzdjy3y7D+8yaXXMje40exsjJdh7JcF667Iyqb w62Mf2hkBWqFMcu27vO5BuSpLpkG/2VgwUyAbKGpZcefl0AgpgWvlch3GfBa9LWa 9I9Thax96UdQY2paGvHOMHyPEvaR4DzCgSCAqsEOQLOuK9smtcCtTbibxufbiXdx 5bz01o3tJ8s4E6n0JCCTjc/LvIOdtNfzgG2Sb6Q1cS6Hbg6XAr5miqiy5BANhvKi gl8aPNd6a57UrixiaCRjsnM66JTisgAc/zHTk3mvWqFNHddUSdGuAZj3qlSPh7Gw svMAyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194780; x=1795799580; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=/7s8ABkw8A0jDP5RoPLduBdGQ6lnCYdbqKkIWsykgw0=; b=K34gujJ2AdPaa8KdNZyr2WcuyvR0hhP1IxChVv5st3n3RCSQXZBjPUtgrGcoI/7kag D9C/cmcscvPNQO+6x6F9Dk5HZj6XVHLtdtnvJGmHi1GgiAktS6Xz5bXiuBj1BYoiglBN hS/jQDBxkkuqIVpYG2PLCsTarGzFvzrW55+H/S3w3yffmFKg9kmGMzJB95TVRqS1a9QU RiFwGtOCTNMcvX6mHA97s025ChnJ12rBENTX0dmpPlnBjjoHHSmd7ogrC8M6hvVV0xts smg6FoIWnmrtFkk8JcdG3179GVJ0H1T8KOtVaU5jGMDuk8DqdJn0U9GIMEk5++grWmMs YqKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194780; x=1795799580; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/7s8ABkw8A0jDP5RoPLduBdGQ6lnCYdbqKkIWsykgw0=; b=b0sOXvQHKyfFIQH2nzW/5COUNw6lQt9vt2bV7Qlk5q9/gzBnb/zLPbriJHDONrhrHJ 1wrSwUFrKCtbqOj5na6CKAkGj3VfVSUgmSh1A+esan15cMwi4/jhkaLtyoyIM3LimeZT wC19ohHabYinQP0rSe1hekBAtB3kJTlCMmiJh5Bgkqyfsr3qnuFqE52wEbVM8JqOh3JE hffzrJK1LxJpeU6UHJS4A8TcN+FbfQtfPSZU9s2N6Xw93VIzvmnQ7Mt/ux8Gwe2HC20C 19iFL8A4hNJV+ZJbgoV/IHdr9xNLDkraAMOn3lgs87MHb82XkNnP0wJd0OEOWaczT5Vi 72KQ== X-Gm-Message-State: APuU4Z9GL+6UChHIfuFBQ3DZwv5pkt8G9oDZYqL1poQT60F2smpCOjNv S/TtmjJHHUzy3Ef4muntqSFcjQP7/1WYw7CO0b4w6EiqfBzHcAxOhTEUHohXoa72s6OsLNGAJyM iyhc7PgObxlA4QQ7DCZkGgdrURJbxk12rrOekk9PBXMs0tTCO49kzaqI9uqMg/5mlyg== X-Gm-Gg: AYBFou2dqApn4nnjsz1v/uCoYzNGEI2Ol+wHuqj2/TiSEMDXRo0q9dhkOrXtJlQSrNf 3P57woR/FMuq3Jcdqxfkrmp0n6JWoh5Jd9NUiwffMP1Ytx+vf4YT7CMziQPtmBcNxNDLARzFAz2 cJ7YCs2gK9ktbv44RqtMZpyK34tNTWrWMUa9v0rTaw+xx9aEsWfdzq+goaEesIEtNuPndyLVTCs mkmEwDKupdxudsB6G9l902PUEIJOnauBqWbM+79YmGukgdI1EtmUEEs1yFEfHTBWXl43MbI6mGb nptHpQHNCSlEXv36bxR8osZN+vN+BRnni8bLjc9V/+nl2Azhfa+VzIrSk7MvRgpgLhu3mfBUKms 3+YiCTNS15qHTyiwyAD4MzIGxdrSQT9dsegkzqXCYxBSMhKfRRs1KlLXVE3LqPq32GZDPB98Tdw nCwPNGPyaD/W8kOA== X-Received: by 2002:a05:620a:628b:b0:93f:6f8:9d72 with SMTP id af79cd13be357-949bac7c684mr520717885a.77.1795194780199; Fri, 20 Nov 2026 09:13:00 -0800 (PST) X-Received: by 2002:a05:620a:628b:b0:93f:6f8:9d72 with SMTP id af79cd13be357-949bac7c684mr520711085a.77.1795194779478; Fri, 20 Nov 2026 09:12:59 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2 v4 03/14] hw/scsi/scsi-disk: Add quirk_mode_page_no_flexible_disk, use it on the 715 Date: Fri, 20 Nov 2026 18:12:23 +0100 Message-ID: <20261120171235.61325-4-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=Dt/Da2/+ c=1 sm=1 tr=0 ts=6b007f9d cx=c_pps a=UgVkIMxJMSkC9lv97toC5g==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=2MoOl1b4q7AZYG_WMiUA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=1HOtulTD9v-eNWfpl4qZ:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-GUID: cYBxlBH2pY-hTaPshkoaVbr2-hGgjvHJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXxq7s5+NjCs8I mHEjYiUTkfYAUwzlOGRTrd2DKP37HZ9dMRUh4UYbwPha+ZqQHXRnmsV75Z3qKjdBrIXm4HPOwR2 avYEl+PP+JKLcqUhm2Oamm69Ql3oD3S3pmUVLAG5g+JHQF2ZcMPQ30JS2dBgVs8bCk5+tLLso3z v+o09WewbWk3NQsLUfQEe7H7+jaesQFO9hEluriegNEGnwUw9Vh0XJHT84aRXCoRus9HHZ+u1xm FMkyaHd5v7WKihFBMlZari5kGaLYmmPE1qYF27IoVkj/elKYcN42gxO5bC5hg4VxFGbERfU9rwn s7aSgKHArCLZPo+Y/p1kuRnayCpHk2VzQHibQn16x3KvuYBXjwcO4ScZ7IaSHuvooWkxe89Nll0 ZAnEpuJiUMMbnkkqKFj+Zhk7umf+HDvYu/oi4CuwkuZWUJeh4adLO8gUzA62CJsTMFKq5ELCF3r 5VVP++9P09Bn78NL+0w== X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX7j92b2XHgN3h Y3meNc0Zo+Rl7tzniPp2GJjl3oVTSk0CwNXMt1ekoD5F3ivH55WhktXny2ZJXhDso9+TEOKN2Ox GU2f4MhjpMcnz0/W+7bnUdKW+kZ7QRs= X-Proofpoint-ORIG-GUID: cYBxlBH2pY-hTaPshkoaVbr2-hGgjvHJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194866582158500 From: Keith Monahan scsi-disk answers MODE SENSE for page 05h (flexible disk geometry) for every disk. Per the commit author, real SCSI hard disks of that era reject this page with CHECK CONDITION, ILLEGAL REQUEST, INVALID FIELD IN CDB, as only floppy drives implement it. This has not been verified against real hardware or a datasheet here. Per the commit author, HP-UX 9 on the HP 715 probes page 05h on the open root disk and, when the page is returned, treats the disk as a floppy and leaves it out of the ioscan listing, so SAM shows no hard disk. This guest behaviour has not been reproduced here. Add the quirk_mode_page_no_flexible_disk property, which makes page 05h an invalid field in the CDB, and enable it for scsi-hd on the HP 715 machine through its compat properties. The property is also defined for scsi-cd, like the other mode page quirks, as both device types share mode_sense_page() and the same quirks bitmap; the 715 does not enable it there. The array name hw_compat_715 suggested a versioned machine compat table, which it is not; call it hp_715_scsi_quirks. AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/scsi/scsi.h | 1 + hw/hppa/machine.c | 10 ++++++++++ hw/scsi/scsi-disk.c | 13 +++++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index a2f6f0be7fce..0efa62554d50 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -264,5 +264,6 @@ bool scsi_generic_pr_state_cleanup(SCSIDevice *s, Error= **errp); #define SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE 2 #define SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED 3 #define SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE 4 +#define SCSI_DISK_QUIRK_MODE_PAGE_NO_FLEXIBLE_DISK 5 =20 #endif diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 8a3f673daf75..2c9114995aad 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -1024,6 +1024,14 @@ static void HP_A400_machine_init_class_init(ObjectCl= ass *oc, const void *data) mc->default_ram_size =3D 1024 * MiB; } =20 +/* + * HP-UX 9 ioscan sends MODE SENSE page 5 to the open root disk and leaves + * the disk out of its listing if the page is returned. + */ +static GlobalProperty hp_715_scsi_quirks[] =3D { + { "scsi-hd", "quirk_mode_page_no_flexible_disk", "on" }, +}; + static void HP_715_machine_init_class_init(ObjectClass *oc, const void *da= ta) { static const char * const valid_cpu_types[] =3D { @@ -1045,6 +1053,8 @@ static void HP_715_machine_init_class_init(ObjectClas= s *oc, const void *data) mc->max_cpus =3D MIN_CONST(HPPA_MAX_CPUS, 8); mc->default_ram_size =3D 256 * MiB; mc->default_nic =3D TYPE_LASI_82596; + compat_props_add(mc->compat_props, hp_715_scsi_quirks, + G_N_ELEMENTS(hp_715_scsi_quirks)); } =20 =20 diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index a2df3a4ec464..ce43ddf6c062 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1156,6 +1156,15 @@ static int mode_sense_page(SCSIDiskState *s, int pag= e, uint8_t **p_outbuf, return -1; } =20 + /* + * The flexible disk page is only implemented by floppy drives. Some + * guests (HP-UX 9 ioscan) take a disk that returns it for a floppy. + */ + if (page =3D=3D MODE_PAGE_FLEXIBLE_DISK_GEOMETRY && + (s->quirks & (1 << SCSI_DISK_QUIRK_MODE_PAGE_NO_FLEXIBLE_DISK))) { + return -1; + } + /* * If Changeable Values are requested, a mask denoting those mode para= meters * that are changeable shall be returned. As we currently don't support @@ -3293,6 +3302,8 @@ static const Property scsi_hd_properties[] =3D { 0), DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState, quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0), + DEFINE_PROP_BIT("quirk_mode_page_no_flexible_disk", SCSIDiskState, + quirks, SCSI_DISK_QUIRK_MODE_PAGE_NO_FLEXIBLE_DISK, 0), DEFINE_BLOCK_CHS_PROPERTIES(SCSIDiskState, qdev.conf), }; =20 @@ -3401,6 +3412,8 @@ static const Property scsi_cd_properties[] =3D { SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED, 0), DEFINE_PROP_BIT("quirk_mode_page_set_block_size", SCSIDiskState, quirks, SCSI_DISK_QUIRK_MODE_PAGE_SET_BLOCK_SIZE, 0), + DEFINE_PROP_BIT("quirk_mode_page_no_flexible_disk", SCSIDiskState, + quirks, SCSI_DISK_QUIRK_MODE_PAGE_NO_FLEXIBLE_DISK, 0), }; =20 static void scsi_cd_class_initfn(ObjectClass *klass, const void *data) --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194885; cv=none; d=zohomail.com; s=zohoarc; b=T59Z5piAFAIQEkvYqbHRqLJXK759WHyCoAQYpGt2BxnONHj2lQZ5SY3iWQwrSq2gybYX3yKELDNUJX9SLPR3gSewWOLbp8V+EgzV2ck10YdJoQmP53jqgaXBpOPHxlxo3rCczXk34y8azmi+z3Oxa+kmQnMIjLJ3aqHzikS0hEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194885; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JmdLh6eIpLeeHj6fyYX4hd0YOlk1E6eEip2rEcS+gxQ=; b=WYczFKdfTqn+vB04hRbibqX6ryhx7OMDn/0IRLUiKp6hKChTH2N/kre4j1DM5rt1isgjUhZi7RLILXUitdl5YIBo+TRY2dqQ/okoG56esHLWSEO/4bWi8KE1MthuiX1/5C2IBzmi67C6OhV+KpJoYVehbsMhYUEnQVjCNO7bGxI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194885440163.6972726730163; Fri, 20 Nov 2026 09:14:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBU-0003WZ-Vf; Fri, 20 Nov 2026 12:14:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAg-0002zt-JQ for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:13 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAf-0003qo-4O for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:10 -0500 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKH0aNw1882370 for ; Fri, 20 Nov 2026 17:13:08 GMT Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2t7vg1uj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:07 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-93909014c85so234370285a.0 for ; Fri, 20 Nov 2026 09:13:07 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb9067846esm497385e9.4.2026.11.20.09.13.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= JmdLh6eIpLeeHj6fyYX4hd0YOlk1E6eEip2rEcS+gxQ=; b=UOXVXQ21kUDvXeo6 v6x/mjIsqD49g06ZL0Qb+ehaUWOYnY98HslG0onr+LwyfIGHCLZXbz7U60IjItAa Ps926VX0cIXuUPy0jJsFwV/MsFkcZ599lez7KAFehg1S1Z3q5cgmZxL5bHRyYsga FaI36+D1dRsmnJ/1BsXcvGHyOPuRDDOR4/uW19bONanUG/Ts9+JIftyQ34ed+rZJ sPd9+rQuRoyE+knUozAfHeamoYwPYcT0JfBaysK2Tr3+IFb8tduhVD4k2H8La7y9 n6nWK9mESYQjOc8kff7iNLIyJtUS0dcceoXHQaQYnmwsGRdHn8BcSObE5Zwwm5If s4suTA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194787; x=1795799587; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=JmdLh6eIpLeeHj6fyYX4hd0YOlk1E6eEip2rEcS+gxQ=; b=dstexu5Z81PiYyvHIpODbr7ujbi3jokacqEYgnxpaPSWLt8xi6YxfU08/kp02glHiU OVfYxaYKdpFIaSAxfYQcHEw9ZR/ARwiVPa3CCmVjviqqogGQ1FgT6aSuZbYQ5jCmHq1C y467jT1EgaoLckhM9ptyFrXH23pOjkpRwCXKNvek/zti9hxIS2kZuM6pIsBHwhLDcS41 mjSLX16VYfiHCB0KB57Nw+LW7PB+njpRX/oNQIC0+PfQabyTcVDf775ZZ4exxlN2wxrN jCiUwx/gOMEMJ2y6D/zB0rToIDhk0BrSvC6Os4umYWDwTnxaM/VjRkWyM5LFgPt4vqf3 elog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194787; x=1795799587; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=JmdLh6eIpLeeHj6fyYX4hd0YOlk1E6eEip2rEcS+gxQ=; b=1MclH//dmAphi7jiV7UsKr9p5AtKgUZiuRea1p+RLWVGMyrdpCTgnoyTyGjxTfHtGA TiaOKd3s5hLYGnn0oUx3Uv0GTDTXv5JI+wDV7iJgyHDVxqrBs+XT2q69Ivhm+udaUgEe xUQD9lM1l4gjK4Qp2egJ6xJtUhvfZeMLO05PdrhpyWOdDVHnXJZ6s9mTwtHG5KZSt3Lr CdYZpe92+YKvaobpAQk0v4tOp9hhit7K68A7l0J1uFPXj7u58FvKLF9/6pkV2/wuubbL s3Z4V1bnjMdDGTE2xPNoyEqXTYY8yEMRrtVcykNFlJ6zIqfVrht8myxZD1E1Iy9gdwxo Dwpw== X-Gm-Message-State: APuU4Z8JVGONrZ9AZ6Cr9SmpZ3RxjfSOQ+mFvDbbAXSNOABKiyS8Fr1m dOxVpS4p+aTUxjm5YlXiXaSs2yJQYhHyrGtOez9PEhm5P/Vtg2lMRR//6Ih0kvsfvl8Sze1SHSd UjUoGxCI6YqurlOrNUyX+LYY10BA+jY2jTqrzyXyd3IQXWS4+Tm6AewnNZZhabXQqJw== X-Gm-Gg: AYBFou04qofs8l4ljnnw0t0w/PuDgoiF5oKQwrU+g4Zs7JbqVY71dLycvIXj/t353t+ zSTZXQTQ9MYhkq8jzk+m4gtFPajD2wCOklOG4pcyhIHadfU7NgLcbxD13AA2q1qfanOAxIRwA8c lD33Kapb4/cBb4EIHO7Sw6OsuVAmGce6pa4my+Hb2ynNoG23io5BC89BUQGmsymcI40GlDk1m42 JtQxGLP2EPxeDfJKpD96SlnMfTLlbvGGzD5jUvzClhChs3jMbBOcER9DEv3Arni380JJHALWoHA ggZiD+gL3Ue1jV2uVrwwxA7oq6tJjDYDp4vwL3m3QHaka/WBRdDhDPmcGGQsG6m4jTTELZK0Tzf ymw76KmcsMyZGvoy+KcbOJZiHrHwzf7WwCiYP5A2Dlu5no6QCGcQX+tjWmakj3fF+/MK9feTJpa QV3UUOgRoHuMRRzw== X-Received: by 2002:a05:620a:468d:b0:93e:d051:8f19 with SMTP id af79cd13be357-949ba9b3950mr620271785a.40.1795194787018; Fri, 20 Nov 2026 09:13:07 -0800 (PST) X-Received: by 2002:a05:620a:468d:b0:93e:d051:8f19 with SMTP id af79cd13be357-949ba9b3950mr620265585a.40.1795194786529; Fri, 20 Nov 2026 09:13:06 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2 v4 04/14] hw/scsi/lasi_ncr710: Limit max_target and max_lun to 7 Date: Fri, 20 Nov 2026 18:12:24 +0100 Message-ID: <20261120171235.61325-5-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: -aAGqVtKBRXICrID4mxHhsdcg9Kn1MNR X-Authority-Analysis: v=2.4 cv=BZZNQbt2 c=1 sm=1 tr=0 ts=6b007fa3 cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=WsAls44tjjwPSMURo_4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-ORIG-GUID: -aAGqVtKBRXICrID4mxHhsdcg9Kn1MNR X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX576YYmkI2ky0 zflJaa9jByM1vou6dO1GGREBPHOQtC0vejYf8NA1Cw+IZTZT69+GU9ulecGh4Cj75/rrn1G2RT9 ODve1S2UWBLiCgvxgftso0tpJoHTfC8= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX4LLoXXAUkzrK E/+3hxlKH3uj4R5vc+ago/3YtAh+p/mtAj9BM5e9EsxE5j+vnbkwL0Ia4n51U1kW3/R84zlKBh8 zoivKDMQc4J6Sm6U5XF7sRDyO3uT4q6eezLysNmb0BZfC/yBYpBE2OurYXs+K6KeFNhQAduiR6p NAPW4ET3o5MP+vSGzyFrI4/BVG+naO/HoIz+lDKszM/A0RkjhgI0kijiTnb7sEoput2DyVjNHBA WSGrx09QQxClbOgqQnTHyYTJ1Ra8bK9uUVZm4iTou5CbBrXZbXD4lgh9wHMGreUyywcJwva4fV2 1DiDhU0lJut6Akb9cEio14uNfBIGle2y+vHGQEwQtTIGfoSXmrLK7cgcxXgYl3WJ/3UKafPno1X uxeKmNZ+0l0aQ2XdVkeS9T05ij0FveX9jLWsRJwzhTM0Ua2p5hZD/mTHseQR7B56UEkGmZ9/X2t kxj0JgEEx9wjlMnSqEg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194886544158500 SCSI target IDs and LUNs on this bus are 3-bit values, so the highest valid one is 7. scsi-bus.c treats max_target and max_lun as inclusive limits (id > max_target is rejected), so 8 wrongly allowed an ID and a LUN that the chip cannot address. This matches esp.c and esp-pci.c. AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lasi_ncr710.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi/lasi_ncr710.c b/hw/scsi/lasi_ncr710.c index 4fde2265b5be..27234aadd390 100644 --- a/hw/scsi/lasi_ncr710.c +++ b/hw/scsi/lasi_ncr710.c @@ -137,8 +137,8 @@ static void lasi_ncr710_command_complete(SCSIRequest *r= eq, size_t resid) =20 static const struct SCSIBusInfo lasi_ncr710_scsi_info =3D { .tcq =3D true, - .max_target =3D 8, - .max_lun =3D 8, /* full LUN support */ + .max_target =3D 7, + .max_lun =3D 7, =20 .transfer_data =3D lasi_ncr710_transfer_data, .complete =3D lasi_ncr710_command_complete, --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194841; cv=none; d=zohomail.com; s=zohoarc; b=RPdQOSNysV2GuPy0Xq10UsRmvIX2JXJttPs6tBNntzv7Fk5nFAOKXe41WhKyEATWcHHMW5/NGdFIQThwGO+gcwX8+Tyz/WSAtdLpyzVYAc+Jm9Mp8HCcBEmOoSJxcf0DbPdLP8mp3ZXyLEbY7AemB9Ok4DXBfINqging3Yqz7hY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194841; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=idgvY+a6R+Z+I3NHKy2UDJP7pusobRCKTbr/NYjb26E=; b=Bw/mkHNok2tu2/jj344dU5CMMDzxzOKIP3U8LnavkbU36pq38xME3+rPlZ+H9DfzJQCT7u6D1SsblkoKS653YSm3dtMNMBaAwuqMHe219X3583tHaF+AN80b8QTGm2K6D/bfhNX8YatsiwoT8o+Q8C1Pp6jUOUS/B+6P8Um0Qqw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194841307389.57134584678624; Fri, 20 Nov 2026 09:14:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBG-0003H0-5e; Fri, 20 Nov 2026 12:13:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAn-000312-Tf for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:18 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAm-0003rT-7C for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:17 -0500 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfYgp1680243 for ; Fri, 20 Nov 2026 17:13:15 GMT Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j27b5vt2f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:15 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-949b0d322fcso206521285a.2 for ; Fri, 20 Nov 2026 09:13:15 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb88402ce9sm80090705e9.0.2026.11.20.09.13.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= idgvY+a6R+Z+I3NHKy2UDJP7pusobRCKTbr/NYjb26E=; b=f/NUiyXoozKFImor sWGfYhowrtGmV+MHmgSyEh1cx5zf67lqNUXlXaRXqL5eEWdClc4RABbhCdqlXVlk 3XU/Ea5KcYTw3vQEnI0/tA3eb8oY5sV2dSvZGk3klj2Mofa5FeOllpZIBWH+xkOK qcirwAUio73NxCiNzwgrEKi/NpZm75cGx/HZQ2YuOsyBiZ+yEIegSD/3d5xll8xI iMiYUeXPXmHLhqj/RIWkWZCTYvWUSAOVnSkdN5xBfIaKEIQTvJIt4CZfcad8R+ZQ OO52yTjtlcLYMVh76UBZ2/A0nPVatuPCvAApUjvm6RJKp0d8nJrlB92Z5C/nagdw tXYYlA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194795; x=1795799595; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=idgvY+a6R+Z+I3NHKy2UDJP7pusobRCKTbr/NYjb26E=; b=SAo7gE5f3gJpAfKnUYLvZmzTYqCWRPpm+jyZjvt+1QURc6O+SpZ5czEHMaQeRDdhYy Pp7LckXAwITh3XnxgBHye0zUXlgy0TfZz+lulhDWe/ij5W4oo+CS427oFOPM0XoMp+S1 Mr8uFNW+d8SPQF8hDez6i7BvMlRNVru/G1QSGQfn5TWBmYVKo1WcOpvHuNmIBcUl3Pk5 6agsMhY4i3Sluvbmk51N68iYEnv0o2Z/DpksDWXF6/bDHXAXks7tQ7qhvW3v3idWF9z8 TtIueqd0vBqcr+gOZZeFzVR8sh/7v4BQ7xQPlFSasqoygmzFPRE/33+97S//Xa8e+3qs 1zAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194795; x=1795799595; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=idgvY+a6R+Z+I3NHKy2UDJP7pusobRCKTbr/NYjb26E=; b=Y3irNEnVOLgGbN+MI0SSB48U1do3bhVNYsZjetj3YxVkw7cs9HkmitJhAax45Kmau0 3HqICG1tXPxEg3h1ziioG2aMWBMQT2reocfLS9U9VhNIElvpAnjP7oLVRqyLXqvA/9bc sbFJe3wvQiX8J0WKVSkeUFcFtthaXb7AJeS+a4EfZ2lnLBUkzqCPwdNsjHRrNCP6vi1T nRJQVZBpPI7/Nh9SgL7kFCOCRkmGbtoMfyFgeAiAuBIddEKqYHrfVgHjVDGjsfVayhBJ NnGri4+iGrrgeknWI0KyVlwxmVmwOPqpJrosZgC2O0CYCz+Ix3EZCzmFw0HCNOPoPhKE Ct6A== X-Gm-Message-State: APuU4Z8bmMllR4K9odH4YzfAyVj+Li38YODzEQ56eKlL7XymzVUmp9Zd JUne2KT2bOc9cSv4cyyrbBRFeifHnm0yOw6ZIIiln6koTVEaWwT1yeKzxQ8FSKY+8pqpRAXfRlb akj+YmOkfbEJrHBpQEaScPg7WUSBHBukkNbVnHw8EdnsLCUKOzSB9JJTVBhuGgcjfOQ== X-Gm-Gg: AYBFou2NdzrGcRFBgfUS4MwSAGwHH3hg4cPgIUGq++kswa+eGvc90JMjK5J8xi0l8rW ZVJ62Dj2qlbCmEilBj37AkKARavvSlfI48MHdDfGcYI3FC5oYXqGoYUTN+1VenN9JbXYXuGz6zj jyLq/K1clia+eoGmNe3yCQjABUIuPllk/df6fmI4cinss8XXMGdRyAnQoQz9l9q7K4SYbDPzgv5 IOTlFWcsSKzG0do/hiBLS8R4h+tTUDdeUzbnb61I4DEBtRdM5VZmIFNv6ILWgooulZV9E0dZ7lW w7P/2zWslQzw8aYnePgmpg8RNzLCd165ynK5NOUbIEFoH+sXw64HAJtonig6iEiSvlZnIO4CFaO F1MrdsDFWiUkm3WhEyQtiVkWHe9jk85VVKChUEAt3z1uF7jkIA+A6sCR/VelHTNnvEP0nRzwza/ 5Zfq7HN0R8hJpxqA== X-Received: by 2002:a05:620a:6605:b0:947:920d:662d with SMTP id af79cd13be357-949ba9a2e20mr599519685a.35.1795194794549; Fri, 20 Nov 2026 09:13:14 -0800 (PST) X-Received: by 2002:a05:620a:6605:b0:947:920d:662d with SMTP id af79cd13be357-949ba9a2e20mr599508385a.35.1795194793529; Fri, 20 Nov 2026 09:13:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2 v4 05/14] hw/scsi/ncr53c710: Keep DCNTL.EA and DMODE.FC1 across an ISTAT.RST reset Date: Fri, 20 Nov 2026 18:12:25 +0100 Message-ID: <20261120171235.61325-6-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXwSi87+MFZliP TF695VObWOlYddOjXYYuMEWLB3zPiuo6H8b4WNYbmLakhV8P/3cEYJLhS/5PusflloqPy+o+WmG WeSkvOUagK9fgjiQndpUCPc/QybLiVQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX9p5LMh4tyOXv q7WTpSgxusXFwTxJF+tzWyF0iil93pB4xZ+0HbX47DJc/QYzr+E11NMyOVFIxzt/loZE2xEb1yE NahuaNEE51yeDn2FTk/PR0zh6g2HCkhmsHi0UenaeGPYIhVxcmgo9Leo5esui/M/93u29Wnup1Y w6/ahkbzbI2LjBAWRJvm542vhBOVfOoqSKaeVpQM7K9lQCr26YsC4hACpa+5gHVBTD+pSd84Z13 NUZ8SE3u+YDNykSptAEggL4boFS3UynmUYRGccdIHZwCnQNvyIbGlnAkuoqtrL1nkpx03Xpmcqs 5a628q0lsVsCe35l2ek25uEablD1Doe/rKkvZd6H3pwQat1gVLOSz0Qaoh1gtqAR1vY0kW6zpnI xt85sZbsDpoxrM5S9b/45YTLWrGTOqo+FtQMpoCnSw63u8FR02bk5WlS2hM4k/T0FqMab6HT9sS 6YdSjD3yyfF5ndK6P3w== X-Proofpoint-GUID: 5W0-KeeRl1h3RYM7zhLDrWAezCGwKu0x X-Proofpoint-ORIG-GUID: 5W0-KeeRl1h3RYM7zhLDrWAezCGwKu0x X-Authority-Analysis: v=2.4 cv=LPTz05W9 c=1 sm=1 tr=0 ts=6b007fab cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=m1ZtPpK_mvkRyh5kXggA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 spamscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194842189158500 The NCR 53C710 data manual, ISTAT bit 6 (RST) description, says the software reset clears all registers except that "This reset will not clear the Enable Acknowledge (EA) or Function Control One (FC1) bits". EA is DCNTL bit 5 and FC1 is DMODE bit 4. ncr710_soft_reset() cleared both registers entirely. Add named defines for the two bits and preserve them in the soft reset. ncr710_soft_reset() is also used for device reset and realize, which must still clear both bits, so those callers (the LASI reset and realize handlers and the sysbus reset handler) now zero DCNTL and DMODE after calling it. The effect on real guest drivers has not been tested. AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.h | 5 +++++ hw/scsi/lasi_ncr710.c | 6 ++++++ hw/scsi/ncr53c710.c | 7 +++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/scsi/ncr53c710.h b/hw/scsi/ncr53c710.h index 00b6a01577c0..7dd0fe5f7589 100644 --- a/hw/scsi/ncr53c710.h +++ b/hw/scsi/ncr53c710.h @@ -85,6 +85,11 @@ #define NCR710_DCNTL_REG 0x3B /* DMA Control */ #define NCR710_ADDER_REG 0x3C /* Adder Sum Output (32-bit, LE) */ =20 +/* DMODE bit 4: Function Code 1 (FC1), kept by an ISTAT.RST soft reset. */ +#define NCR710_DMODE_FC1 0x10 +/* DCNTL bit 5: Enable Acknowledge (EA), kept by an ISTAT.RST soft reset. = */ +#define NCR710_DCNTL_EA 0x20 + #define NCR710_REG_SIZE 0x100 =20 #define NCR710_BUF_SIZE 4096 diff --git a/hw/scsi/lasi_ncr710.c b/hw/scsi/lasi_ncr710.c index 27234aadd390..27d8b5c74935 100644 --- a/hw/scsi/lasi_ncr710.c +++ b/hw/scsi/lasi_ncr710.c @@ -186,6 +186,9 @@ static void lasi_ncr710_realize(DeviceState *dev, Error= **errp) &s->ncr710); =20 ncr710_soft_reset(&s->ncr710); + /* A device reset clears EA and FC1; only ISTAT.RST keeps them. */ + s->ncr710.dcntl =3D 0; + s->ncr710.dmode =3D 0; =20 trace_lasi_ncr710_timers_initialized( (uint64_t)s->ncr710.reselection_retry_timer); @@ -246,6 +249,9 @@ static void lasi_ncr710_reset(DeviceState *dev) LasiNCR710State *s =3D LASI_NCR710(dev); trace_lasi_ncr710_device_reset(); ncr710_soft_reset(&s->ncr710); + /* A device reset clears EA and FC1; only ISTAT.RST keeps them. */ + s->ncr710.dcntl =3D 0; + s->ncr710.dmode =3D 0; } =20 static void lasi_ncr710_instance_init(Object *obj) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 9ea2c47744e7..55153418e409 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -349,8 +349,8 @@ void ncr710_soft_reset(NCR710State *s) s->ctest5 =3D 0; s->dsp =3D 0; s->dsps =3D 0; - s->dmode =3D 0; - s->dcntl =3D 0; + s->dmode &=3D NCR710_DMODE_FC1; + s->dcntl &=3D NCR710_DCNTL_EA; s->scntl0 =3D 0xc0; s->scntl1 =3D 0; s->sstat0 =3D 0; @@ -2266,6 +2266,9 @@ static void ncr710_device_reset(DeviceState *dev) NCR710State *s =3D &sysbus_dev->ncr710; =20 ncr710_soft_reset(s); + /* A device reset clears EA and FC1; only ISTAT.RST keeps them. */ + s->dcntl =3D 0; + s->dmode =3D 0; } =20 static const struct SCSIBusInfo ncr710_scsi_info =3D { --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194924; cv=none; d=zohomail.com; s=zohoarc; b=KSweVf3+z16YnyW7re871+jJ3YzquM2weNtg0biXNSYg84WzZQIs5aYddgwjcLmn3Qujyp368thfX+pMvZ5JmWiBcGaXmtXDLYj/xSCf4PQJsodwhLN7EqvIVWRQdH5DrOg697RTE8PEWSCfS/c+u+NHieuJRXMbjrB+dur/7N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194924; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uB5/bMacb5OjTMQkWD+5M2U9BZH4TIH3WwZFjcJ3OIk=; b=lo9rS24XX40Zq8kRjowXSn6Fo2uO3J4M73zMn8xXrbtS4eFKaeydgV02EuBRFp0wqyUzN8ew6QPZb69VTJj2j1VHDeWIuu3cgm/txN10BDzjv0SFKvTFJcwpglnDzCC13ha7UotL7tWO3yqvoRMZfPZocOl9G26pEjIwuLBslvM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194924412817.5394286044161; Fri, 20 Nov 2026 09:15:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSC7-0004P7-Be; Fri, 20 Nov 2026 12:14:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAw-00034E-B4 for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:30 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSAu-0003sD-8V for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:26 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfGI42039946 for ; Fri, 20 Nov 2026 17:13:22 GMT Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjttxw3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:22 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93909014c85so234415885a.0 for ; Fri, 20 Nov 2026 09:13:22 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884a3a3dsm90318495e9.10.2026.11.20.09.13.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= uB5/bMacb5OjTMQkWD+5M2U9BZH4TIH3WwZFjcJ3OIk=; b=GbFnm2s4Fc4Dl/N+ PJt9+7UNypXkwOFu9kdeQPdt3awX5vJ20OoAAEgj07+IT06NM9MKDf7TaW/FnunD mVi1G7bDUH0U/LyqYMKKPvKVb3JejqV74kx2PtQOf1M3+BTrjkps6f0dndDuBGxO 94hS1uec16NbMoW0fSZxFwPNT0QLHspNTn5/JDAlH4d8Wyt0SyTclWuQ02GfhNfP +FuT4794xw0gKo7auxezaVc9koxt+lJEMiELT62gsd3LX0A9zsGvNNvyCEnIkoW4 jQn0sXIndE3TmI2h0WeEnahaMbBIezYeoqtoxzOMoWf2bH9p25EHwyPauFGSSGEI f/IlVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194802; x=1795799602; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=uB5/bMacb5OjTMQkWD+5M2U9BZH4TIH3WwZFjcJ3OIk=; b=WFSOM11ZSXDsPABVFjv1wDp0qSr8r1JdR/S/A3vj38pPI4SAaSn9SUAIzvYZS8xyz/ 9cR6li0Cyfk5uHd+7qJyhWGsNmOxiVzqi+hxIFZ8oU6F5jBMmgJXHIAOcm8GGnQR3CX6 AzZ7Xj6vAeEsjMeLtmdkW7w1XUCt7s9xAuUWroG8rjWtx0MXXSzx41idYd4z/lc02y6f zrTqZNYUyH3/r/vvR3lYOcbidKO8peOs3C/sfcgH9U9yHTJY/9+ST74xEKUGQL7eJHYR zd3qI3TLjzlkZzFoNbMZg2V9vMGB8mikSJXLkj8exLg3EWvhrnBJ1hM5snUnANwRngvb N5VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194802; x=1795799602; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=uB5/bMacb5OjTMQkWD+5M2U9BZH4TIH3WwZFjcJ3OIk=; b=DdxRhiZRm5umtxtTY7cA00U0EEjHdEOa9mZui8QHyAGDbWMO33W4tURVkPri9DY0xa 2m13gaM8rYMLwxKlNzz945naZ4huuXpPPKgqKeeVe5r66TOo83CfTbNlViU0pXI+829l Phyuz7MyUL8Kx4eCjSaXspZ6k8ub0UiAP9gpZaEZwp9Wqgvqk4F8nmr2B62sjzcXffDk lKn4zmGe/nc4AkNP/XCNoGWqHWxyxl3vUOg7ul583Tqf2kAh98MKT/ZXpdOVJPBwcMIc nYOWW2p05f562gLhpKbumePAqpgnZg2g2hoLoT3DugPm2pXUV/tnC5d99RVECIBsj2pJ xK0A== X-Gm-Message-State: APuU4Z96qVMeMRFEORQ9O5vI+fMsxlTOe17KagkUxybjk3VaUY28sPXb ngLmwY8jxGQGhUig4/EaHI/9UtCTdjOG4S+Hfj5qjJanfj5NqizKH6nSXsCYKUPM/P+mCtaLxdF i7BDyU7BXyWr9Oc7GwjrbnY7ocSBtpAy+arSSAf7e8//6fvjAGEum9H+3n5VqNlOaPQ== X-Gm-Gg: AYBFou2fi7SI9gV+yv/LwjZ2QDyJeULsL6DOXOxPiQzmJhJ8P1+o0t3clSaIJxO3do2 xsuSZtsYQozpFu/3HbWAKfYguZ5pJB0VJPOxtWV8Pst69Ck6GRw8LWXU9jQM4z3bgiGYrEH57zi E6GfRPRPcV3CepJMZR/0quOj1dfX4OqXpQIvKfAomMoIqE/0o3dUl3d0nopk3AR65UlgOfC6z6r sG8SFXMGW+GUpnlT84lH4yTgg7RHfssjteexJtHmmWjJuy3kDv1jwqKVcp5p4kaA5k7+bC7fXsJ ZBenMRc24NjD3sjGzvdf3EAUM0dDDCZoSjDEAW4dHL1v0BHvcYrU7eNuTH0m5UPHW1brag8h13b c6BTGBMoGyyaY5FcgJ2YuGmGdUke5aP7FfQJKryplthTp4WI38i3ITTMNJ9nwH5yBrDc1tmDwPX o4QDTW2VN1bg26lA== X-Received: by 2002:a05:620a:28c8:b0:949:7acc:1695 with SMTP id af79cd13be357-949ba6c5900mr578759385a.0.1795194801463; Fri, 20 Nov 2026 09:13:21 -0800 (PST) X-Received: by 2002:a05:620a:28c8:b0:949:7acc:1695 with SMTP id af79cd13be357-949ba6c5900mr578750585a.0.1795194800636; Fri, 20 Nov 2026 09:13:20 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 06/14] hw/scsi: Move shared LSI/NCR definitions to lsi_scsi.h Date: Fri, 20 Nov 2026 18:12:26 +0100 Message-ID: <20261120171235.61325-7-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: uvNR_E4zKmdPkj3J9klCALazTwIA0y2l X-Proofpoint-GUID: uvNR_E4zKmdPkj3J9klCALazTwIA0y2l X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXzRKJ9npTCETj ATs4tlzKjalft/wSkccqEXUZXwWAkD+JPSPl1k93WnqQEbCaBBQMx5S7oebozN51aijyfP0yC/t NpqrjiFtONOwe8qrWZRn32Y6HXq2hcCAaUJOF6lz5RuHLTWzOKT2Y93wMzjCWNEzNvlhqxx3aMj bOgKomgZlYx2kYU5NcKqe3XqFmYOtq79UYtTE0yO+jOg42b3As3PqjqliXu4lXn9e9e2bN4V81d zJP9VTIUCRM1acVnq2+18aIFRK2MBurlqMysG4AVJObshZqvmCcuC+3ScvUGA5OkiDgvWervZZo 4cxaBawWSni8773IyFNNpx80AVixe5txbg0JVdy2rxZzi8sA7r0tPT9BHYDYJ9XyFS6tnzHMKQB baOYwIC2lg0tbg8w3+I4Cs489oejmvf1piiORZxmMH8B7kambH3szbLgA/hmYPNfuT+15KTWMTb A7ZhefRTWesVdO8Lsow== X-Authority-Analysis: v=2.4 cv=XcccX455 c=1 sm=1 tr=0 ts=6b007fb2 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=vlC4I3SjAAAA:8 a=7q4XBQtiWicnC9o1hGEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 a=AAPjE2N9MkmuCaafd2wf:22 a=MGyrNx-tFZ9jfgWML-M_:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX772Vdd0Yzpz/ 3tdmcF67xQCY3zsFOH2uVeaZdglvHYoi3KY+48pEAoInXLFYqwGC5/jVrVhipiyv9tZ0IrZhTkb fFBOAnasISp0MZpcPjmz6UTCeEiXVL0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194924874158500 From: Keith Monahan Move common defines and structures of the lsi53c895a driver to lsi_scsi.h so that the 53c710 driver can share them. Pure code movement, no functional change: nothing is renamed and the lsi53c895a device is unchanged. Licence: the moved code comes from lsi53c895a.c, which is licensed under the LGPL (Copyright (c) 2006 CodeSourcery, written by Paul Brook), so the new header keeps that licence (SPDX LGPL-2.1-or-later) rather than the preferred GPL-2.0-or-later; it is not relicensed. Suggested-by: BALATON Zoltan Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: BALATON Zoltan --- MAINTAINERS | 1 + hw/scsi/lsi_scsi.h | 104 +++++++++++++++++++++++++++++++++++++++++++ hw/scsi/lsi53c895a.c | 79 +------------------------------- 3 files changed, 106 insertions(+), 78 deletions(-) create mode 100644 hw/scsi/lsi_scsi.h diff --git a/MAINTAINERS b/MAINTAINERS index 3a9b4d34a0fc..752519a7f82f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2431,6 +2431,7 @@ R: Fam Zheng S: Supported F: include/hw/scsi/* F: hw/scsi/* +F: hw/scsi/lsi_scsi.h F: tests/qtest/virtio-scsi-test.c F: tests/qtest/fuzz-virtio-scsi-test.c F: tests/qtest/am53c974-test.c diff --git a/hw/scsi/lsi_scsi.h b/hw/scsi/lsi_scsi.h new file mode 100644 index 000000000000..de0941dd23a7 --- /dev/null +++ b/hw/scsi/lsi_scsi.h @@ -0,0 +1,104 @@ +/* + * QEMU LSI53C895A SCSI Host Bus Adapter emulation + * Definitions shared with other NCR/LSI SCRIPTS based controllers + * + * Copyright (c) 2006 CodeSourcery. + * Written by Paul Brook + * + * This code is licensed under the LGPL. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef HW_SCSI_LSI_SCSI_H +#define HW_SCSI_LSI_SCSI_H + +#include "qemu/queue.h" +#include "hw/scsi/scsi.h" + +#define LSI_SCNTL0_TRG 0x01 +#define LSI_SCNTL0_AAP 0x02 +#define LSI_SCNTL0_EPC 0x08 +#define LSI_SCNTL0_WATN 0x10 +#define LSI_SCNTL0_START 0x20 + +#define LSI_SCNTL1_AESP 0x04 +#define LSI_SCNTL1_RST 0x08 +#define LSI_SCNTL1_CON 0x10 +#define LSI_SCNTL1_ADB 0x40 +#define LSI_SCNTL1_EXC 0x80 + +#define LSI_ISTAT0_DIP 0x01 +#define LSI_ISTAT0_SIP 0x02 +#define LSI_ISTAT0_CON 0x08 +#define LSI_ISTAT0_SIGP 0x20 +#define LSI_ISTAT0_SRST 0x40 +#define LSI_ISTAT0_ABRT 0x80 + +#define LSI_SOCL_ATN 0x08 + +#define LSI_DSTAT_IID 0x01 +#define LSI_DSTAT_SIR 0x04 +#define LSI_DSTAT_SSI 0x08 +#define LSI_DSTAT_ABRT 0x10 +#define LSI_DSTAT_BF 0x20 +#define LSI_DSTAT_DFE 0x80 + +#define LSI_DCNTL_COM 0x01 +#define LSI_DCNTL_STD 0x04 +#define LSI_DCNTL_SSM 0x10 + +#define LSI_DMODE_MAN 0x01 + +#define LSI_CTEST2_DACK 0x01 +#define LSI_CTEST2_SIGP 0x40 + +#define LSI_SBCL_ATN 0x08 +#define LSI_SBCL_BSY 0x20 +#define LSI_SBCL_ACK 0x40 +#define LSI_SBCL_REQ 0x80 + +#define PHASE_DO 0 +#define PHASE_DI 1 +#define PHASE_CMD 2 +#define PHASE_ST 3 +#define PHASE_MO 6 +#define PHASE_MI 7 +#define PHASE_MASK 7 + +/* Maximum length of MSG IN data. */ +#define LSI_MAX_MSGIN_LEN 8 + +/* Flag set if this is a tagged command. */ +#define LSI_TAG_VALID (1 << 16) + +/* Maximum instructions to process. */ +#define LSI_MAX_INSN 500 + +typedef struct lsi_request { + SCSIRequest *req; + uint32_t tag; + uint32_t dma_len; + uint8_t *dma_buf; + uint32_t pending; + int out; + bool orphan; + QTAILQ_ENTRY(lsi_request) next; +} lsi_request; + +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 */ + LSI_WAIT_SCRIPTS, /* SCRIPTS stopped because of instruction count limi= t */ +}; + +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, +}; + +#endif diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 1b7f02fc7c91..2a7c6e9c8dc9 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -18,6 +18,7 @@ #include "hw/core/irq.h" #include "hw/pci/pci_device.h" #include "hw/scsi/scsi.h" +#include "lsi_scsi.h" #include "migration/vmstate.h" #include "system/dma.h" #include "qemu/log.h" @@ -42,20 +43,9 @@ static const char *names[] =3D { =20 #define LSI_MAX_DEVS 7 =20 -#define LSI_SCNTL0_TRG 0x01 -#define LSI_SCNTL0_AAP 0x02 -#define LSI_SCNTL0_EPC 0x08 -#define LSI_SCNTL0_WATN 0x10 -#define LSI_SCNTL0_START 0x20 - #define LSI_SCNTL1_SST 0x01 #define LSI_SCNTL1_IARB 0x02 -#define LSI_SCNTL1_AESP 0x04 -#define LSI_SCNTL1_RST 0x08 -#define LSI_SCNTL1_CON 0x10 #define LSI_SCNTL1_DHP 0x20 -#define LSI_SCNTL1_ADB 0x40 -#define LSI_SCNTL1_EXC 0x80 =20 #define LSI_SCNTL2_WSR 0x01 #define LSI_SCNTL2_VUE0 0x02 @@ -66,14 +56,8 @@ static const char *names[] =3D { #define LSI_SCNTL2_CHM 0x40 #define LSI_SCNTL2_SDU 0x80 =20 -#define LSI_ISTAT0_DIP 0x01 -#define LSI_ISTAT0_SIP 0x02 #define LSI_ISTAT0_INTF 0x04 -#define LSI_ISTAT0_CON 0x08 #define LSI_ISTAT0_SEM 0x10 -#define LSI_ISTAT0_SIGP 0x20 -#define LSI_ISTAT0_SRST 0x40 -#define LSI_ISTAT0_ABRT 0x80 =20 #define LSI_ISTAT1_SI 0x01 #define LSI_ISTAT1_SRUN 0x02 @@ -105,43 +89,30 @@ static const char *names[] =3D { #define LSI_SOCL_IO 0x01 #define LSI_SOCL_CD 0x02 #define LSI_SOCL_MSG 0x04 -#define LSI_SOCL_ATN 0x08 #define LSI_SOCL_SEL 0x10 #define LSI_SOCL_BSY 0x20 #define LSI_SOCL_ACK 0x40 #define LSI_SOCL_REQ 0x80 =20 -#define LSI_DSTAT_IID 0x01 -#define LSI_DSTAT_SIR 0x04 -#define LSI_DSTAT_SSI 0x08 -#define LSI_DSTAT_ABRT 0x10 -#define LSI_DSTAT_BF 0x20 #define LSI_DSTAT_MDPE 0x40 -#define LSI_DSTAT_DFE 0x80 =20 -#define LSI_DCNTL_COM 0x01 #define LSI_DCNTL_IRQD 0x02 -#define LSI_DCNTL_STD 0x04 #define LSI_DCNTL_IRQM 0x08 -#define LSI_DCNTL_SSM 0x10 #define LSI_DCNTL_PFEN 0x20 #define LSI_DCNTL_PFF 0x40 #define LSI_DCNTL_CLSE 0x80 =20 -#define LSI_DMODE_MAN 0x01 #define LSI_DMODE_BOF 0x02 #define LSI_DMODE_ERMP 0x04 #define LSI_DMODE_ERL 0x08 #define LSI_DMODE_DIOM 0x10 #define LSI_DMODE_SIOM 0x20 =20 -#define LSI_CTEST2_DACK 0x01 #define LSI_CTEST2_DREQ 0x02 #define LSI_CTEST2_TEOP 0x04 #define LSI_CTEST2_PCICIE 0x08 #define LSI_CTEST2_CM 0x10 #define LSI_CTEST2_CIO 0x20 -#define LSI_CTEST2_SIGP 0x40 #define LSI_CTEST2_DDIR 0x80 =20 #define LSI_CTEST5_BL2 0x04 @@ -163,59 +134,11 @@ static const char *names[] =3D { #define LSI_CCNTL1_DDAC 0x08 #define LSI_CCNTL1_ZMOD 0x80 =20 -#define LSI_SBCL_ATN 0x08 -#define LSI_SBCL_BSY 0x20 -#define LSI_SBCL_ACK 0x40 -#define LSI_SBCL_REQ 0x80 - /* Enable Response to Reselection */ #define LSI_SCID_RRE 0x60 =20 #define LSI_CCNTL1_40BIT (LSI_CCNTL1_EN64TIBMV|LSI_CCNTL1_64TIMOD) =20 -#define PHASE_DO 0 -#define PHASE_DI 1 -#define PHASE_CMD 2 -#define PHASE_ST 3 -#define PHASE_MO 6 -#define PHASE_MI 7 -#define PHASE_MASK 7 - -/* Maximum length of MSG IN data. */ -#define LSI_MAX_MSGIN_LEN 8 - -/* Flag set if this is a tagged command. */ -#define LSI_TAG_VALID (1 << 16) - -/* Maximum instructions to process. */ -#define LSI_MAX_INSN 500 - -typedef struct lsi_request { - SCSIRequest *req; - uint32_t tag; - uint32_t dma_len; - uint8_t *dma_buf; - uint32_t pending; - int out; - bool orphan; - QTAILQ_ENTRY(lsi_request) next; -} lsi_request; - -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 */ - LSI_WAIT_SCRIPTS, /* SCRIPTS stopped because of instruction count limi= t */ -}; - -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, -}; - struct LSIState { /*< private >*/ PCIDevice parent_obj; --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194872; cv=none; d=zohomail.com; s=zohoarc; b=UwyZXUNnrJ1y2IPmW/8cAgDU1fklvR3VPcvVqwmBTg/4/n3wf2IRWr5XXYygMxOKWWDdcYafqhje05/DEbJzMhUGc1WW1ud5js+B6GCLungYKS/DMsELsr/U2RwMr3XkvssGHiwobMN37yHbHGIQJQ5dCkixXQhKT3JtAvaMLcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194872; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yDj7zR0+jrieW9blHTcGGoxo7locFu7n1zEAq59y3Ec=; b=Z1NQ3lpcVJAhcRVkwI808UzT5RlpOv9eY2hUWemgONmomZhqsv2VdvHT6+/IHPK1+eC4zf41BXKvWCqhGxLMSAkjBaRDcfB089KuH6tfBSEJRZuRJ2P8950foPsL2wTpVdS3VduTqxnx2FcL0HdEI8G5cONbW0nU1SgVu6klK6E= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194872863338.7116913356441; Fri, 20 Nov 2026 09:14:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBZ-0003dM-Iv; Fri, 20 Nov 2026 12:14:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSB9-0003Fz-A9 for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:41 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSB4-0003sw-7X for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:39 -0500 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKH0aO21882370 for ; Fri, 20 Nov 2026 17:13:33 GMT Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2t7vg1wa-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:32 +0000 (GMT) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-9213c7a506fso12449926d6.1 for ; Fri, 20 Nov 2026 09:13:32 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6baa3882sm6798541f8f.49.2026.11.20.09.13.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= yDj7zR0+jrieW9blHTcGGoxo7locFu7n1zEAq59y3Ec=; b=M+FFXj2GPWCSkLKE WhYIWjAFunBaIWhC0bhIhlF09m6VFOKsGSVUmY3dYaZtbMzhb0IAl+P39p6EAoDG rzpUUQGejRBFtWLl1cds73sc1+FD/JAycDKHIWX3JjPKkz3bhcNHn9NqXQFt/0Se s6bnd3UCCuLg0CjFcOpTkO7sUWkFnYTiZJswCcO8QRpRDDeZ9QT7c2G4qP5Cl/GE u78CRxW6McRWSzGlW6yw+KmSCBfeQfJGUR2ocyZgGBLN+9Eww6gKcVGQ5IYtuNK5 0Kjf0hUTXe38MCGP3xFb7xRe+Zgl5MvRp+2yeB0oONnPuw+g/cKnJkkKmOSKOHmZ NjP3yg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194812; x=1795799612; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yDj7zR0+jrieW9blHTcGGoxo7locFu7n1zEAq59y3Ec=; b=ZUOCUfcWV0bTIvboo29AYeDz9gR0lAuwqlBN1sc6m7LRB4VXNpn77n47R+rAXttnnO K1B2ShXaLWC6B51UxQyCS5ukr3LeBj/R6TyZKTLq/t/C17m9dni1HE7ZDw2edXBT0570 lXdAUgGYm/l/FYjujnJLlail7OAYSm5BMBV0zkYJ76SBh5nTKxxBV/jb5vAMpJ4PEMFk CZ3WU4PwuPaeXjXZFs21yLCH3xdCNz1xpUwoIofO64i+yqh9EOAWLyb49vouDOFWhban NeZWVgR9Fl+Tnap4nN0JwcLXtWGidvLuvFPowXy4DiQdCaNbgjpfo3GhKK+nTJVHddE3 wSug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194812; x=1795799612; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yDj7zR0+jrieW9blHTcGGoxo7locFu7n1zEAq59y3Ec=; b=CHLvckj0wD0ZCxxwzB1RueCd45BQ33kq874NXjqOMzbCtLOP8szCNMzKgA9GJRf5bk 7JnR10T+P6Win6PTnzkncOpcq/LKaJT7+GXqDiM59vnTbm4vQ8aPJ2sXoCSPhjx/eBdx xdfjHFSjBnGDRe9I/DJjFICCEeJP+kujn2KyOrTAz86a9qzW3BTxMo0gnT84m3t85ZwN Ys5C8HFEflWwgx49kqDMZBZ7/Qf08jw8L6crGACJBIivk2hgSTCfzgvGzm7KVUrjB772 Nnq5C0kdwKyAjdc/gweNNyh+zbh7QtGt9LqBlZj3MOhBDVwGTSNH5rduu9dBBHaAVO9o MdWw== X-Gm-Message-State: APuU4Z+55rCHarA5iIjcWKdclqjmtrKuXB53X3WiiQCZ7tr4phIFxuOB U1Yef0k5grSATiS9RFmBLwOMK1uA0XEcqxMttMKQl2bK1KGf7Yvmsc3nX8tjvq7sIoyhvu/8ULV 26AEyx55vYU25/sIO1ris3MPYENlWhMPrmpcW+1deviYojVhlmkRl22/XSwe+mPYzyw== X-Gm-Gg: AZFdTZf3xksZ3LKxB0revomlmLwl1R7DaBCKXYJrKTq6bNjZBpaBvigp33mDScR4+gr emBKUlRkmMbZN88KEr/9/g3X3rki5JcvSc852sdI46XbHP793gXTTOIXgRvgspARiMuvvWXgjYS a8+304q2M3fw57KfAq0zOTWtHfUwM2Zs6aiSbj54nnGVOJ7ItNlWWdPWeiN0vlqyeVK9qrJOGYH uVEesxXoSHiS1wQ7ZQSvSn2D6BNQr/xicDdR9ZkpTREAR4orSIHVr245M10hNWHVy/Nanmq19xa +NMXEkzMsHPLM4kuCLKgu2H3ErxN4zYXKBr3+geWQb98QOQYuKVIy1GYL7vAsXVKmnRV0uvD98D RIiJDWRXx89szEk0Qd1CdgfdGyGh7BlDvAZgsa4jxxnMKXhgQ5TydKvUA7bdzM1PdW2hMyVtp8H SF7eEwAgoMnoKJHw== X-Received: by 2002:a05:620a:8394:b0:949:75de:b22b with SMTP id af79cd13be357-949ba81a715mr596134585a.2.1795194810158; Fri, 20 Nov 2026 09:13:30 -0800 (PST) X-Received: by 2002:a05:620a:8394:b0:949:75de:b22b with SMTP id af79cd13be357-949ba81a715mr596114885a.2.1795194808218; Fri, 20 Nov 2026 09:13:28 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2??? v4 07/14] hw/scsi/ncr53c710: Rewrite the 53C710 SCRIPTS engine Date: Fri, 20 Nov 2026 18:12:27 +0100 Message-ID: <20261120171235.61325-8-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: SKtNetYZWQU-G-eMBgf1QdO9vqTVXSx0 X-Authority-Analysis: v=2.4 cv=BZZNQbt2 c=1 sm=1 tr=0 ts=6b007fbc cx=c_pps a=wEM5vcRIz55oU/E2lInRtA==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=7j3OZyEV7kwyqF-wk7wA:9 a=s6AiloRwYEDpqUs3:21 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=OIgjcC2v60KrkQgK7BGD:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-ORIG-GUID: SKtNetYZWQU-G-eMBgf1QdO9vqTVXSx0 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX4qRGDoGvfF1U 1r3it+x6s/ZTmNUdDkLecBu0Amii9FazEOhoipJehmYsVsPHICloBNKdZ3WI9ICW1Y1Z7B1UKSm 2Ze+loJZGpZJGO3+DATr6IfZ2vMbIm4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX9KatYU8dX8Tu DUcTaBLKVBahmWi2w9N66ejtVo1wLq5IEhjGYmb9YjPXinanCGvjaLpYAPeULCmSkQiEvc5S4XH S7I4Lfbv97+cuZLcf34QPZWKeCbBi7ig34jEbnG0sD2XrU6YpyuL/1rus3ZSzoCBHpOMfqZ2cYO nuaMJ/EP4CEJbZ3JsS5oWf8eBluom+GdMGGm8V+bqGEjEj53PetatAGwvMPXSCr431wZxJZGwLw 1NbvHwWiIdPFjiA2ukff0ranv4QtFFWrKB0Xq+yyiAx+YJMa605qpERPYcKxX4rMvnnzAWqO+S2 rG9VlF+2P7pQsJvrkgSIiG/V/FJo1mYDFgwGfe7KmUSCh1AIVjmW0WyvtbnTGM1xtTK0onzsacH 9GDXZLEJP+07NB3uPRIj7CrpKnqo/H/8vMnDaYANK9VoCp4HOXV1lwgNdt/dqYonK0IL8LY/2c1 UgiAxA1AZEhj318YYEg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194874631158500 From: Keith Monahan Rewrite the NCR 53C710 model with a SCRIPTS engine derived from QEMU's LSI53C895A model (hw/scsi/lsi53c895a.c), an actively maintained sibling in the same NCR/LSI SCRIPTS family, adapted to the 53C710: its register map, single byte (DSTAT/SSTAT0) interrupt model, big endian SCRIPTS and table indirect fetch (the part sits on the big endian PA-RISC LASI bus), and 24 bit DMA counts. Behaviour follows the NCR 53C710 Data Manual (Jun 1992) and Programmer's Guide (Oct 1990). The LASI glue (hw/scsi/lasi_ncr710.c) is the only instantiated device and embeds one NCR710State by value. It gains the free_request SCSIBusInfo callback and request queue init the new core needs, renames the reselection timer to scripts_timer, and drops the old model's dead scaffolding (the unused SCNR define, the DPRINTF macros, and unused or shadowing register macros). Disconnect and reselect, adapted from lsi53c895a, let a driver overlap tagged commands: a disconnecting command's request moves onto a per device queue and is reselected once its data is ready and the engine is parked at Wait Reselect. Reselection follows the 53C700 family rather than the 8xx parts: gated on the (re)selection interrupt enable (SIEN.SEL) alone, one hot SDID, an SFBR id bitmask in 700 compatibility mode, and IDENTIFY (plus SIMPLE QUEUE TAG when tagged) replayed on reconnect. A disconnect is fabricated only for a tagged command under a driver that parks on Wait Reselect with SIEN.SEL clear, which today means HP-UX; untagged transfers and reselection interrupt drivers (e.g. Linux 53c700) keep the existing connected completion path. SDTR/WDTR/PPR negotiation is declined with MESSAGE REJECT. Completion deferral, the synchronous drain, the HP-UX MESSAGE REJECT quirk, the reentrancy guard and the soft reset request cancel are added by the following patches, as is the migration version bump: this patch does not preserve the migration stream of the model it replaces. Derived from hw/scsi/lsi53c895a.c (Copyright (c) 2006 CodeSourcery, written by Paul Brook), which is LGPL; this derived work is distributed under GPL-2.0-or-later, as the LGPL permits. Replaces the 53C710 model written for Google Summer of Code 2025 by Soumyajyotii Ssarkar, itself based on earlier NCR 53C710 work by Helge Deller and by Toni Wilen (for UAE). Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lasi_ncr710.h | 28 +- hw/scsi/ncr53c710.h | 263 ++-- hw/scsi/lasi_ncr710.c | 108 +- hw/scsi/ncr53c710.c | 2843 ++++++++++++++--------------------------- hw/scsi/trace-events | 42 +- 5 files changed, 1131 insertions(+), 2153 deletions(-) diff --git a/hw/scsi/lasi_ncr710.h b/hw/scsi/lasi_ncr710.h index 450fb7e1c3dc..5168f6171568 100644 --- a/hw/scsi/lasi_ncr710.h +++ b/hw/scsi/lasi_ncr710.h @@ -1,12 +1,9 @@ /* - * LASI Wrapper for NCR710 SCSI Controller + * LASI wrapper for the NCR 53C710 SCSI controller * * Copyright (c) 2025 Soumyajyotii Ssarkar - * This driver was developed during the Google Summer of Code 2025 program. - * Mentored by Helge Deller - * - * NCR710 SCSI Controller implementation - * Based on the NCR53C710 Technical Manual Version 3.2, December 2000 + * Developed during Google Summer of Code 2025, mentored by + * Helge Deller . * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -22,29 +19,10 @@ #define TYPE_LASI_NCR710 "lasi-ncr710" OBJECT_DECLARE_SIMPLE_TYPE(LasiNCR710State, LASI_NCR710) =20 -#define LASI_SCSI_RESET 0x000 /* SCSI Reset Register */ -#define LASI_SCSI_NCR710_BASE 0x100 /* NCR710 Base Register Offset */ - -#define PARISC_DEVICE_ID_OFF 0x00 /* HW type, HVERSION, SVERSION */ -#define PARISC_DEVICE_CONFIG_OFF 0x04 /* Configuration data */ - -#define PHASE_MASK 7 -#define PHASE_DO 0 - -#define NCR710_SCNTL1_RST 0x08 /* SCSI Reset */ -#define NCR710_ISTAT_RST 0x40 /* Device Reset */ -#define NCR710_ISTAT_ABRT 0x80 /* Script Abort */ -#define NCR710_ISTAT_CON 0x08 /* ISTAT_Connected */ -#define NCR710_DSTAT_DFE 0x80 /* DMA FIFO Empty */ -#define NCR710_CTEST2_DACK 0x01 /* DMA Acknowledge */ - typedef struct LasiNCR710State { SysBusDevice parent_obj; MemoryRegion mmio; qemu_irq lasi_irq; /* IRQ line to LASI controller */ - uint32_t hw_type; /* Hardware type (HPHW_*) */ - uint32_t sversion; /* Software version */ - uint32_t hversion; /* Hardware version */ NCR710State ncr710; } LasiNCR710State; =20 diff --git a/hw/scsi/ncr53c710.h b/hw/scsi/ncr53c710.h index 7dd0fe5f7589..82202940caa6 100644 --- a/hw/scsi/ncr53c710.h +++ b/hw/scsi/ncr53c710.h @@ -1,13 +1,11 @@ /* - * QEMU NCR710 SCSI Controller + * QEMU NCR 53C710 SCSI I/O Processor emulation * - * Copyright (c) 2025 Soumyajyotii Ssarkar + * Copyright (c) 2026 Keith Monahan * - * NCR710 SCSI Controller implementation - * Based on the NCR53C710 Technical Manual Version 3.2, December 2000 - * - * Developed from the hackish implementation of NCR53C710 by Helge Deller - * which was interim based on the hackish implementation by Toni Wilen for= UAE + * Interface to the 53C710 model (ncr53c710.c). The only instantiated dev= ice is + * the LASI wrapper in lasi_ncr710.c, which embeds one NCR710State by valu= e and + * drives it through the functions declared here. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -15,148 +13,98 @@ #ifndef HW_NCR53C710_H #define HW_NCR53C710_H =20 -#include "hw/core/sysbus.h" +#include "qemu/queue.h" #include "hw/scsi/scsi.h" -#include "qemu/fifo8.h" -#include "qom/object.h" #include "system/memory.h" -#include "hw/core/irq.h" #include "qemu/timer.h" +#include "migration/vmstate.h" +#include "lsi_scsi.h" =20 -#define TYPE_NCR710_SCSI "ncr710-scsi" -#define TYPE_SYSBUS_NCR710_SCSI "sysbus-ncr710-scsi" - -#define SYSBUS_NCR710_SCSI(obj) \ - OBJECT_CHECK(SysBusNCR710State, (obj), TYPE_SYSBUS_NCR710_SCSI) - -#define ENABLE_DEBUG 0 -#if ENABLE_DEBUG -#define DBG(x) x -#define NCR710_DPRINTF(fmt, ...) \ - fprintf(stderr, "QEMU: " fmt, ## __VA_ARGS__) -#define BADF(fmt, ...) \ - fprintf(stderr, "QEMU: error: " fmt, ## __VA_ARGS__) -#else -#define DBG(x) do { } while (0) -#define NCR710_DPRINTF(fmt, ...) do { } while (0) -#define BADF(fmt, ...) do { } while (0) -#endif - -/* NCR710 - Little Endian register Ordering */ -#define NCR710_SCNTL0_REG 0x00 /* SCSI Control Zero */ -#define NCR710_SCNTL1_REG 0x01 /* SCSI Control One */ -#define NCR710_SDID_REG 0x02 /* SCSI Destination ID */ -#define NCR710_SIEN_REG 0x03 /* SCSI Interrupt Enable */ -#define NCR710_SCID_REG 0x04 /* SCSI Chip ID */ -#define NCR710_SXFER_REG 0x05 /* SCSI Transfer */ -#define NCR710_SODL_REG 0x06 /* SCSI Output Data Latch */ -#define NCR710_SOCL_REG 0x07 /* SCSI Output Control Latch */ -#define NCR710_SFBR_REG 0x08 /* SCSI First Byte Received */ -#define NCR710_SIDL_REG 0x09 /* SCSI Input Data Latch */ -#define NCR710_SBDL_REG 0x0A /* SCSI Bus Data Lines */ -#define NCR710_SBCL_REG 0x0B /* SCSI Bus Control Lines */ -#define NCR710_DSTAT_REG 0x0C /* DMA Status */ -#define NCR710_SSTAT0_REG 0x0D /* SCSI Status Zero */ -#define NCR710_SSTAT1_REG 0x0E /* SCSI Status One */ -#define NCR710_SSTAT2_REG 0x0F /* SCSI Status Two */ -#define NCR710_DSA_REG 0x10 /* Data Structure Address */ -#define NCR710_CTEST0_REG 0x14 /* Chip Test Zero */ -#define NCR710_CTEST1_REG 0x15 /* Chip Test One */ -#define NCR710_CTEST2_REG 0x16 /* Chip Test Two */ -#define NCR710_CTEST3_REG 0x17 /* Chip Test Three */ -#define NCR710_CTEST4_REG 0x18 /* Chip Test Four */ -#define NCR710_CTEST5_REG 0x19 /* Chip Test Five */ -#define NCR710_CTEST6_REG 0x1A /* Chip Test Six */ -#define NCR710_CTEST7_REG 0x1B /* Chip Test Seven */ -#define NCR710_TEMP_REG 0x1C /* Temporary Stack */ -#define NCR710_DFIFO_REG 0x20 /* DMA FIFO */ -#define NCR710_ISTAT_REG 0x21 /* Interrupt Status */ -#define NCR710_CTEST8_REG 0x22 /* Chip Test Eight */ -#define NCR710_LCRC_REG 0x23 /* Longitudinal Parity */ -#define NCR710_DBC_REG 0x24 /* DMA Byte Counter (24-bit, LE) */ -#define NCR710_DCMD_REG 0x27 /* DMA Command */ -#define NCR710_DNAD_REG 0x28 /* DMA Next Data Address (32-bit, = LE) */ -#define NCR710_DSP_REG 0x2C /* DMA SCRIPTS Pointer (32-bit, LE= ) */ -#define NCR710_DSPS_REG 0x30 /* DMA SCRIPTS Pointer Save */ -#define NCR710_SCRATCH_REG 0x34 /* Scratch (32-bit, LE) */ -#define NCR710_DMODE_REG 0x38 /* DMA Mode */ -#define NCR710_DIEN_REG 0x39 /* DMA Interrupt Enable */ -#define NCR710_DWT_REG 0x3A /* DMA Watchdog Timer */ -#define NCR710_DCNTL_REG 0x3B /* DMA Control */ -#define NCR710_ADDER_REG 0x3C /* Adder Sum Output (32-bit, LE) */ +/* Register offsets (little endian addressing; the chip is internally LE).= */ +#define NCR710_SCNTL0 0x00 +#define NCR710_SCNTL1 0x01 +#define NCR710_SDID 0x02 +#define NCR710_SIEN 0x03 +#define NCR710_SCID 0x04 +#define NCR710_SXFER 0x05 +#define NCR710_SODL 0x06 +#define NCR710_SOCL 0x07 +#define NCR710_SFBR 0x08 +#define NCR710_SIDL 0x09 +#define NCR710_SBDL 0x0a +#define NCR710_SBCL 0x0b +#define NCR710_DSTAT 0x0c +#define NCR710_SSTAT0 0x0d +#define NCR710_SSTAT1 0x0e +#define NCR710_SSTAT2 0x0f +#define NCR710_DSA 0x10 +#define NCR710_CTEST0 0x14 +#define NCR710_CTEST1 0x15 +#define NCR710_CTEST2 0x16 +#define NCR710_CTEST3 0x17 +#define NCR710_CTEST4 0x18 +#define NCR710_CTEST5 0x19 +#define NCR710_CTEST6 0x1a +#define NCR710_CTEST7 0x1b +#define NCR710_TEMP 0x1c +#define NCR710_DFIFO 0x20 +#define NCR710_ISTAT 0x21 +#define NCR710_CTEST8 0x22 +#define NCR710_LCRC 0x23 +#define NCR710_DBC 0x24 +#define NCR710_DCMD 0x27 +#define NCR710_DNAD 0x28 +#define NCR710_DSP 0x2c +#define NCR710_DSPS 0x30 +#define NCR710_SCRATCH 0x34 +#define NCR710_DMODE 0x38 +#define NCR710_DIEN 0x39 +#define NCR710_DWT 0x3a +#define NCR710_DCNTL 0x3b +#define NCR710_ADDER 0x3c =20 /* DMODE bit 4: Function Code 1 (FC1), kept by an ISTAT.RST soft reset. */ #define NCR710_DMODE_FC1 0x10 /* DCNTL bit 5: Enable Acknowledge (EA), kept by an ISTAT.RST soft reset. = */ #define NCR710_DCNTL_EA 0x20 =20 -#define NCR710_REG_SIZE 0x100 - -#define NCR710_BUF_SIZE 4096 -#define NCR710_HOST_ID 7 -#define NCR710_MAX_MSGIN_LEN 8 -#define NCR710_SCSI_FIFO_SIZE 8 - -typedef enum { - NCR710_WAIT_NONE =3D 0, - NCR710_WAIT_RESELECT =3D 1, - NCR710_WAIT_DMA =3D 2, - NCR710_WAIT_RESERVED =3D 3 -} NCR710WaitState; - -typedef enum { - NCR710_CMD_PENDING =3D 0, - NCR710_CMD_DATA_READY =3D 1, - NCR710_CMD_COMPLETE =3D 2 -} NCR710CommandState; - -typedef enum { - NCR710_MSG_ACTION_NONE =3D 0, - NCR710_MSG_ACTION_DISCONNECT =3D 1, - NCR710_MSG_ACTION_DATA_OUT =3D 2, - NCR710_MSG_ACTION_DATA_IN =3D 3 -} NCR710MessageAction; - -typedef struct NCR710State NCR710State; -typedef struct NCR710Request NCR710Request; - -/* - * SCSI FIFO structure - 8 transfers deep, 1 byte per transfer - * (9-bit wide with parity) - */ -typedef struct { - uint8_t data[NCR710_SCSI_FIFO_SIZE]; - uint8_t parity[NCR710_SCSI_FIFO_SIZE]; - int head; - int count; -} NCR710_SCSI_FIFO; - -struct NCR710Request { - SCSIRequest *req; - uint32_t tag; - uint32_t dma_len; - uint32_t pending; - uint8_t status; - bool active; - uint8_t *dma_buf; - bool out; - uint32_t resume_offset; - uint32_t saved_dnad; -}; - -struct NCR710State { - SysBusDevice parent_obj; - MemoryRegion mmio; - qemu_irq irq; +/* The chip revision reported in CTEST8[7:4]. */ +#define NCR710_CHIP_REVISION 0x2 =20 +typedef struct NCR710State { + /* Wiring filled in by the LASI wrapper before ncr710_soft_reset(). */ SCSIBus bus; AddressSpace *as; + qemu_irq irq; + /* + * SCRIPTS yield/resume timer, mirroring lsi53c895a's scripts_timer. = The + * wrapper creates it. + */ + QEMUTimer *scripts_timer; =20 - /* Registers */ + /* SCRIPTS engine working state (not directly register mapped). */ + int carry; + int status; + int msg_action; + int msg_len; + uint8_t msg[LSI_MAX_MSGIN_LEN]; + int waiting; + int current_lun; + uint32_t select_tag; + int command_complete; + bool script_running; + lsi_request *current; + /* Disconnected tagged commands awaiting reselection. */ + QTAILQ_HEAD(, lsi_request) queue; + + /* + * Registers (53C710 layout). Several (e.g. sodl/sidl/sbdl/lcrc/ctest= *) are + * readback/scratch only, with no modelled side effects. + */ uint8_t scntl0; uint8_t scntl1; uint8_t sdid; - uint8_t sien0; + uint8_t sien; uint8_t scid; uint8_t sxfer; uint8_t sodl; @@ -171,14 +119,10 @@ struct NCR710State { uint8_t sstat2; uint32_t dsa; uint8_t ctest0; - uint8_t ctest1; - uint8_t ctest2; uint8_t ctest3; uint8_t ctest4; uint8_t ctest5; - uint8_t ctest6; uint8_t ctest7; - uint8_t ctest8; uint32_t temp; uint8_t dfifo; uint8_t istat; @@ -194,58 +138,21 @@ struct NCR710State { uint8_t dwt; uint8_t dcntl; uint32_t adder; - - NCR710_SCSI_FIFO scsi_fifo; - - NCR710Request *current; - uint8_t status; - uint8_t msg[NCR710_MAX_MSGIN_LEN]; - uint8_t msg_len; - uint8_t msg_action; /* NCR710MessageAction values */ - int carry; - bool script_active; - int32_t waiting; /* NCR710WaitState values */ - uint8_t command_complete; /* NCR710CommandState values */ - - QEMUTimer *reselection_retry_timer; - uint32_t saved_dsps; - - uint32_t select_tag; - uint8_t current_lun; - uint8_t reselection_id; - bool wait_reselect; -}; - -typedef struct SysBusNCR710State { - SysBusDevice parent_obj; - MemoryRegion mmio; - MemoryRegion iomem; - qemu_irq irq; - NCR710State ncr710; -} SysBusNCR710State; +} NCR710State; =20 static inline NCR710State *ncr710_from_scsi_bus(SCSIBus *bus) { return container_of(bus, NCR710State, bus); } =20 -static inline SysBusNCR710State *sysbus_from_ncr710(NCR710State *s) -{ - return container_of(s, SysBusNCR710State, ncr710); -} - -DeviceState *ncr53c710_init(MemoryRegion *address_space, hwaddr addr, - qemu_irq irq); -DeviceState *ncr710_device_create_sysbus(hwaddr addr, qemu_irq irq); -void ncr710_reg_write(void *opaque, hwaddr addr, uint64_t val, unsigned si= ze); -uint64_t ncr710_reg_read(void *opaque, hwaddr addr, unsigned size); +/* Interface used by the LASI wrapper (lasi_ncr710.c). */ +uint64_t ncr710_reg_read(NCR710State *s, hwaddr addr, unsigned size); +void ncr710_reg_write(NCR710State *s, hwaddr addr, uint64_t val, unsigned = size); void ncr710_soft_reset(NCR710State *s); void ncr710_request_cancelled(SCSIRequest *req); void ncr710_command_complete(SCSIRequest *req, size_t resid); void ncr710_transfer_data(SCSIRequest *req, uint32_t len); -void ncr710_execute_script(NCR710State *s); -void ncr710_set_phase(NCR710State *s, int phase); -void ncr710_reselection_retry_callback(void *opaque); +void ncr710_scripts_timer_callback(void *opaque); extern const VMStateDescription vmstate_ncr710; =20 #endif /* HW_NCR53C710_H */ diff --git a/hw/scsi/lasi_ncr710.c b/hw/scsi/lasi_ncr710.c index 27d8b5c74935..cbb04017ce9c 100644 --- a/hw/scsi/lasi_ncr710.c +++ b/hw/scsi/lasi_ncr710.c @@ -1,12 +1,12 @@ /* - * LASI Wrapper for NCR710 SCSI Controller + * LASI wrapper for the NCR 53C710 SCSI controller * * Copyright (c) 2025 Soumyajyotii Ssarkar - * This driver was developed during the Google Summer of Code 2025 program. - * Mentored by Helge Deller + * Developed during Google Summer of Code 2025, mentored by + * Helge Deller . * - * NCR710 SCSI Controller implementation - * Based on the NCR53C710 Technical Manual Version 3.2, December 2000 + * LASI module glue mapping the 53C710 core in ncr53c710.c onto the HP 715 + * (-M 715) LASI bus. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -24,7 +24,6 @@ #include "system/dma.h" =20 #define LASI_710_SVERSION 0x00082 -#define SCNR 0xBEEFBABE #define LASI_710_HVERSION 0x3D #define HPHW_FIO 5 /* Fixed I/O module */ =20 @@ -34,8 +33,6 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwaddr= addr, LasiNCR710State *s =3D LASI_NCR710(opaque); uint64_t val =3D 0; =20 - trace_lasi_ncr710_reg_read(addr, 0, size); - if (addr =3D=3D 0x00) { /* Device ID */ val =3D (HPHW_FIO << 24) | LASI_710_SVERSION; trace_lasi_ncr710_reg_read_id(HPHW_FIO, LASI_710_SVERSION, val); @@ -51,22 +48,22 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwad= dr addr, if (addr >=3D 0x100) { hwaddr ncr_addr =3D addr - 0x100; if (size =3D=3D 1) { + /* + * Single byte access: flip the byte lane (PA-RISC big endian + * access -> the chip's little endian register order). + */ ncr_addr ^=3D 3; - NCR710_DPRINTF("Reading value to LASI WRAPPER =3D=3D 0x%lx%s, " - "val=3D0x%lx, size=3D%u\n", - addr - 0x100, size =3D=3D 1 ? " (XORed)" : "", - val, size); val =3D ncr710_reg_read(&s->ncr710, ncr_addr, size); } else { + /* + * Multibyte access: gather little endian, no lane flip, so + * the 24/32 bit registers assemble correctly. + */ val =3D 0; for (unsigned i =3D 0; i < size; i++) { uint8_t byte_val =3D ncr710_reg_read(&s->ncr710, ncr_addr = + i, 1); val |=3D ((uint64_t)byte_val) << (i * 8); - NCR710_DPRINTF(" Read byte %u from NCR addr 0x%lx: " - "0x%02x\n", i, ncr_addr + i, byte_val); } - NCR710_DPRINTF(" Reconstructed %u-byte value: 0x%lx\n", - size, val); } =20 trace_lasi_ncr710_reg_forward_read(addr, val); @@ -84,7 +81,11 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr a= ddr, =20 trace_lasi_ncr710_reg_write(addr, val, size); =20 - if (addr <=3D 0x0F) { + /* + * 0x00..0x0f is the read only LASI module header (ID/SVERSION/HVERSIO= N); + * writes to it are ignored. + */ + if (addr <=3D 0x0f) { return; } =20 @@ -93,16 +94,10 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr = addr, =20 if (size =3D=3D 1) { ncr_addr ^=3D 3; - NCR710_DPRINTF("Writing value to LASI WRAPPER =3D=3D 0x%lx%s, " - "val=3D0x%lx, size=3D%u\n", - addr - 0x100, size =3D=3D 1 ? " (XORed)" : "", - val, size); ncr710_reg_write(&s->ncr710, ncr_addr, val, size); } else { for (unsigned i =3D 0; i < size; i++) { uint8_t byte_val =3D (val >> (i * 8)) & 0xff; - NCR710_DPRINTF(" Writing byte %u to NCR addr 0x%lx: 0x%0= 2x\n", - i, ncr_addr + i, byte_val); ncr710_reg_write(&s->ncr710, ncr_addr + i, byte_val, 1); } } @@ -113,10 +108,7 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr= addr, } } =20 -/* - * req_cancelled, command_complete, transfer_data forwards - * commands to its core counterparts. - */ +/* SCSIBusInfo callbacks: trace, then forward to the ncr53c710 core. */ static void lasi_ncr710_request_cancelled(SCSIRequest *req) { trace_lasi_ncr710_request_cancelled(req); @@ -129,20 +121,27 @@ static void lasi_ncr710_command_complete(SCSIRequest = *req, size_t resid) ncr710_command_complete(req, resid); } =20 - static void lasi_ncr710_transfer_data(SCSIRequest *req, uint32_t len) +static void lasi_ncr710_transfer_data(SCSIRequest *req, uint32_t len) { trace_lasi_ncr710_transfer_data(len); ncr710_transfer_data(req, len); } =20 +static void lasi_ncr710_free_request(SCSIBus *bus, void *priv) +{ + g_free(priv); +} + static const struct SCSIBusInfo lasi_ncr710_scsi_info =3D { .tcq =3D true, + /* 8-bit bus: targets and LUNs 0-7 (scsi-bus.c maxima are inclusive). = */ .max_target =3D 7, .max_lun =3D 7, =20 .transfer_data =3D lasi_ncr710_transfer_data, .complete =3D lasi_ncr710_command_complete, .cancel =3D lasi_ncr710_request_cancelled, + .free_request =3D lasi_ncr710_free_request, }; =20 static const MemoryRegionOps lasi_ncr710_mmio_ops =3D { @@ -160,9 +159,6 @@ static const VMStateDescription vmstate_lasi_ncr710 =3D= { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { - VMSTATE_UINT32(hw_type, LasiNCR710State), - VMSTATE_UINT32(sversion, LasiNCR710State), - VMSTATE_UINT32(hversion, LasiNCR710State), VMSTATE_STRUCT(ncr710, LasiNCR710State, 1, vmstate_ncr710, NCR710S= tate), VMSTATE_END_OF_LIST() } @@ -179,10 +175,11 @@ static void lasi_ncr710_realize(DeviceState *dev, Err= or **errp) &lasi_ncr710_scsi_info); s->ncr710.as =3D &address_space_memory; s->ncr710.irq =3D s->lasi_irq; + QTAILQ_INIT(&s->ncr710.queue); =20 - s->ncr710.reselection_retry_timer =3D + s->ncr710.scripts_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, - ncr710_reselection_retry_callback, + ncr710_scripts_timer_callback, &s->ncr710); =20 ncr710_soft_reset(&s->ncr710); @@ -191,40 +188,26 @@ static void lasi_ncr710_realize(DeviceState *dev, Err= or **errp) s->ncr710.dmode =3D 0; =20 trace_lasi_ncr710_timers_initialized( - (uint64_t)s->ncr710.reselection_retry_timer); + (uint64_t)s->ncr710.scripts_timer); =20 - /* Initialize memory region */ memory_region_init_io(&s->mmio, OBJECT(dev), &lasi_ncr710_mmio_ops, s, "lasi-ncr710", 0x200); sysbus_init_mmio(sbd, &s->mmio); } =20 +static void lasi_ncr710_unrealize(DeviceState *dev) +{ + LasiNCR710State *s =3D LASI_NCR710(dev); + + timer_free(s->ncr710.scripts_timer); + s->ncr710.scripts_timer =3D NULL; +} + void lasi_ncr710_handle_legacy_cmdline(DeviceState *lasi_dev) { LasiNCR710State *s =3D LASI_NCR710(lasi_dev); - SCSIBus *bus =3D &s->ncr710.bus; - int found_drives =3D 0; =20 - if (!bus) { - return; - } - - for (int unit =3D 0; unit <=3D 7; unit++) { - DriveInfo *dinfo =3D drive_get(IF_SCSI, bus->busnr, unit); - if (dinfo) { - trace_lasi_ncr710_legacy_drive_found(bus->busnr, unit); - found_drives++; - } - } - - trace_lasi_ncr710_handle_legacy_cmdline(bus->busnr, found_drives); - - scsi_bus_legacy_handle_cmdline(bus); - BusChild *kid; - QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { - trace_lasi_ncr710_scsi_device_created( - object_get_typename(OBJECT(kid->child))); - } + scsi_bus_legacy_handle_cmdline(&s->ncr710.bus); } =20 DeviceState *lasi_ncr710_init(MemoryRegion *addr_space, hwaddr hpa, @@ -254,20 +237,12 @@ static void lasi_ncr710_reset(DeviceState *dev) s->ncr710.dmode =3D 0; } =20 -static void lasi_ncr710_instance_init(Object *obj) -{ - LasiNCR710State *s =3D LASI_NCR710(obj); - - s->hw_type =3D HPHW_FIO; - s->sversion =3D LASI_710_SVERSION; - s->hversion =3D LASI_710_HVERSION; -} - static void lasi_ncr710_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->realize =3D lasi_ncr710_realize; + dc->unrealize =3D lasi_ncr710_unrealize; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->fw_name =3D "scsi"; dc->desc =3D "HP-PARISC LASI NCR710 SCSI adapter"; @@ -280,7 +255,6 @@ static const TypeInfo lasi_ncr710_info =3D { .name =3D TYPE_LASI_NCR710, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(LasiNCR710State), - .instance_init =3D lasi_ncr710_instance_init, .class_init =3D lasi_ncr710_class_init, }; =20 diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 55153418e409..305958b92f4a 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -1,1497 +1,958 @@ /* - * QEMU NCR710 SCSI Controller + * QEMU NCR 53C710 SCSI I/O Processor emulation * - * Copyright (c) 2025 Soumyajyotii Ssarkar - * This driver was developed during the Google Summer of Code 2025 program. + * Copyright (c) 2026 Keith Monahan + * Copyright (c) 2006 CodeSourcery (lsi53c895a.c, written by Paul Brook) * - * NCR710 SCSI Controller implementation - * Based on the NCR53C710 Technical Manual Version 3.2, December 2000 + * The SCRIPTS engine is derived from QEMU's LSI53C895A model and adapted = to + * the 53C710's register map, single byte interrupt model, big endian SCRI= PTS + * fetch and 24 bit DMA, per the NCR 53C710 Data Manual and Programmer's G= uide. * - * Developed from an implementation of NCR53C710 by Helge Deller - * which was interim based on the implementation by Toni Wilen for UAE. + * Replaces the 53C710 model written for Google Summer of Code 2025 by + * Soumyajyotii Ssarkar , itself based on + * earlier NCR 53C710 work by Helge Deller and by Toni Wilen (for UAE). * * SPDX-License-Identifier: GPL-2.0-or-later - * - * Contents: - * 1. Register Definitions - * 2. Register name functions - * 3. Parity functions - * 4. SCSI FIFO Structures - * 5. Scripts Misc functions - * 6. DMA functions - * 7. Scripts functions - * 8. Read and Write functions - * 9. QEMU Device model functions - * */ =20 #include "qemu/osdep.h" -#include "qapi/error.h" -#include "qemu/timer.h" -#include "hw/core/irq.h" -#include "hw/core/sysbus.h" -#include "hw/scsi/scsi.h" -#include "hw/scsi/ncr53c710.h" -#include "migration/vmstate.h" -#include "system/dma.h" +#include "qemu/bitops.h" #include "qemu/log.h" -#include "qemu/module.h" +#include "qemu/main-loop.h" +#include "hw/core/irq.h" +#include "hw/scsi/ncr53c710.h" +#include "system/block-backend.h" #include "trace.h" -#include "qom/object.h" =20 -#define NCR710_MAX_DEVS 7 +/* SCNTL0 (0x00) */ +#define LSI_SCNTL0_EPG 0x04 =20 -/* SCNTL0 (0x00) - SCSI Control Register 0 */ -#define NCR710_SCNTL0_TRG 0x01 -#define NCR710_SCNTL0_AAP 0x02 -#define NCR710_SCNTL0_EPG 0x04 -#define NCR710_SCNTL0_EPC 0x08 -#define NCR710_SCNTL0_WATN 0x10 -#define NCR710_SCNTL0_START 0x20 -#define NCR710_SCNTL0_ARB0 0x40 -#define NCR710_SCNTL0_ARB1 0x80 +/* SCNTL1 (0x01) */ +#define LSI_SCNTL1_ESR 0x20 =20 -/* SCNTL1 (0x01) - SCSI Control Register 1 */ -#define NCR710_SCNTL1_RES0 0x01 -#define NCR710_SCNTL1_RES1 0x02 -#define NCR710_SCNTL1_AESP 0x04 -#define NCR710_SCNTL1_RST 0x08 -#define NCR710_SCNTL1_CON 0x10 -#define NCR710_SCNTL1_ESR 0x20 -#define NCR710_SCNTL1_ADB 0x40 -#define NCR710_SCNTL1_EXC 0x80 +/* SSTAT0 (0x0d) and SIEN (0x03) share this bit layout. */ +#define LSI_STAT0_PAR 0x01 +#define LSI_STAT0_RST 0x02 +#define LSI_STAT0_UDC 0x04 +#define LSI_STAT0_SGE 0x08 +#define LSI_STAT0_SEL 0x10 +#define LSI_STAT0_STO 0x20 +#define LSI_STAT0_FCMP 0x40 +#define LSI_STAT0_MA 0x80 =20 -/* ISTAT (0x21) - Interrupt Status Register */ -#define NCR710_ISTAT_DIP 0x01 -#define NCR710_ISTAT_SIP 0x02 -#define NCR710_ISTAT_CON 0x08 -#define NCR710_ISTAT_SIGP 0x20 -#define NCR710_ISTAT_RST 0x40 -#define NCR710_ISTAT_ABRT 0x80 +/* DSTAT (0x0c) and DIEN (0x39) share this bit layout. */ +#define LSI_DSTAT_WTD 0x02 =20 -/* SSTAT0 (0x0D) - SCSI Status Register 0 */ -#define NCR710_SSTAT0_PAR 0x01 -#define NCR710_SSTAT0_RST 0x02 -#define NCR710_SSTAT0_UDC 0x04 -#define NCR710_SSTAT0_SGE 0x08 -#define NCR710_SSTAT0_SEL 0x10 -#define NCR710_SSTAT0_STO 0x20 -#define NCR710_SSTAT0_FCMP 0x40 -#define NCR710_SSTAT0_MA 0x80 +/* SBCL (0x0b): low 3 bits mirror the SCSI phase, upper bits are bus signa= ls. */ +#define LSI_SBCL_SEL 0x10 =20 -/* SSTAT1 (0x0E) - SCSI Status Register 1 */ -#define NCR710_SSTAT1_ORF 0x02 -#define NCR710_SSTAT1_ILF 0x04 +/* DCNTL (0x3b) */ +#define LSI_DCNTL_FA 0x02 +#define LSI_DCNTL_LLM 0x08 +#define LSI_DCNTL_EA 0x20 =20 -/* SSTAT2 (0x0F) - SCSI Status Register 2 */ -#define NCR710_SSTAT2_FF0 0x01 -#define NCR710_SSTAT2_FF1 0x02 -#define NCR710_SSTAT2_FF2 0x04 -#define NCR710_SSTAT2_FF3 0x08 +#define LSI_BUF_SIZE 4096 =20 -/* SOCL (0x07) / SBCL (0x0B) - SCSI Output/Bus Control Lines */ -#define NCR710_SOCL_IO 0x01 -#define NCR710_SOCL_CD 0x02 -#define NCR710_SOCL_MSG 0x04 -#define NCR710_SOCL_ATN 0x08 -#define NCR710_SOCL_SEL 0x10 -#define NCR710_SOCL_BSY 0x20 -#define NCR710_SOCL_ACK 0x40 -#define NCR710_SOCL_REQ 0x80 +static const char *const lsi_reg_names[64] =3D { + "SCNTL0", "SCNTL1", "SDID", "SIEN", "SCID", "SXFER", "SODL", "SOCL", + "SFBR", "SIDL", "SBDL", "SBCL", "DSTAT", "SSTAT0", "SSTAT1", "SSTAT2", + "DSA0", "DSA1", "DSA2", "DSA3", "CTEST0", "CTEST1", "CTEST2", "CTEST3", + "CTEST4", "CTEST5", "CTEST6", "CTEST7", "TEMP0", "TEMP1", "TEMP2", "TE= MP3", + "DFIFO", "ISTAT", "CTEST8", "LCRC", "DBC0", "DBC1", "DBC2", "DCMD", + "DNAD0", "DNAD1", "DNAD2", "DNAD3", "DSP0", "DSP1", "DSP2", "DSP3", + "DSPS0", "DSPS1", "DSPS2", "DSPS3", "SCRATCH0", "SCRATCH1", "SCRATCH2", + "SCRATCH3", "DMODE", "DIEN", "DWT", "DCNTL", "ADDER0", "ADDER1", "ADDE= R2", + "ADDER3", +}; =20 -/* SBCL bits same as SOCL */ -#define NCR710_SBCL_IO 0x01 -#define NCR710_SBCL_CD 0x02 -#define NCR710_SBCL_MSG 0x04 -#define NCR710_SBCL_ATN 0x08 -#define NCR710_SBCL_SEL 0x10 -#define NCR710_SBCL_BSY 0x20 -#define NCR710_SBCL_ACK 0x40 -#define NCR710_SBCL_REQ 0x80 - -/* DSTAT (0x0C) - DMA Status Register */ -#define NCR710_DSTAT_IID 0x01 -#define NCR710_DSTAT_SIR 0x04 -#define NCR710_DSTAT_SSI 0x08 -#define NCR710_DSTAT_ABRT 0x10 -#define NCR710_DSTAT_BF 0x20 -#define NCR710_DSTAT_MDPE 0x40 -#define NCR710_DSTAT_DFE 0x80 - -/* DCNTL (0x3B) - DMA Control Register */ -#define NCR710_DCNTL_COM 0x01 -#define NCR710_DCNTL_IRQD 0x02 -#define NCR710_DCNTL_STD 0x04 -#define NCR710_DCNTL_IRQM 0x08 -#define NCR710_DCNTL_SSM 0x10 -#define NCR710_DCNTL_PFEN 0x20 -#define NCR710_DCNTL_PFF 0x40 - -/* DMODE (0x38) - DMA Mode Register */ -#define NCR710_DMODE_MAN 0x01 -#define NCR710_DMODE_BOF 0x02 -#define NCR710_DMODE_ERMP 0x04 -#define NCR710_DMODE_ERL 0x08 -#define NCR710_DMODE_DIOM 0x10 -#define NCR710_DMODE_SIOM 0x20 -#define NCR710_DMODE_BL_MASK 0xC0 -#define NCR710_DMODE_BL_1 0x00 -#define NCR710_DMODE_BL_2 0x40 -#define NCR710_DMODE_BL_4 0x80 -#define NCR710_DMODE_BL_8 0xC0 - -/* CTEST2 (0x16) - Chip Test Register 2 */ -#define NCR710_CTEST2_DACK 0x01 -#define NCR710_CTEST2_DREQ 0x02 -#define NCR710_CTEST2_TEOP 0x04 -#define NCR710_CTEST2_PCICIE 0x08 -#define NCR710_CTEST2_CM 0x10 -#define NCR710_CTEST2_CIO 0x20 -#define NCR710_CTEST2_SIGP 0x40 -#define NCR710_CTEST2_DDIR 0x80 - -/* CTEST5 (0x19) - Chip Test Register 5 */ -#define NCR710_CTEST5_BL2 0x04 -#define NCR710_CTEST5_DDIR 0x08 -#define NCR710_CTEST5_MASR 0x10 -#define NCR710_CTEST5_DFSN 0x20 -#define NCR710_CTEST5_BBCK 0x40 -#define NCR710_CTEST5_ADCK 0x80 - -/* SCID (0x04) - SCSI Chip ID Register */ -#define NCR710_SCID_RRE 0x60 -#define NCR710_SCID_ID_MASK 0x07 - -#define NCR710_HOST_ID 7 - -/* NCR53C710 has 8-byte SCSI FIFO */ -#define NCR710_MAX_MSGIN_LEN 8 -#define NCR710_BUF_SIZE 4096 - -/* Standard SCSI Message Byte Constants */ -#define SCSI_MSG_ABORT 0x06 -#define SCSI_MSG_BUS_DEVICE_RESET 0x0c -#define SCSI_MSG_COMMAND_COMPLETE 0x00 -#define SCSI_MSG_DISCONNECT 0x04 -#define SCSI_MSG_EXTENDED_MESSAGE 0x01 -#define SCSI_MSG_IDENTIFY 0x80 -#define SCSI_MSG_IGNORE_WIDE_RESIDUE 0x23 -#define SCSI_MSG_MESSAGE_PARITY_ERROR 0x09 -#define SCSI_MSG_MESSAGE_REJECT 0x07 -#define SCSI_MSG_NO_OPERATION 0x08 -#define SCSI_MSG_RELEASE_RECOVERY 0x10 -#define SCSI_MSG_RESTORE_POINTERS 0x03 -#define SCSI_MSG_SAVE_DATA_POINTER 0x02 -#define SCSI_MSG_SYNCHRONOUS_DATA_TRANSFER 0x01 -#define SCSI_MSG_WIDE_DATA_TRANSFER 0x03 - -/* Script interrupt codes */ -#define A_GOOD_STATUS_AFTER_STATUS 0x401 -#define A_DISCONNECT_AFTER_CMD 0x380 -#define A_DISCONNECT_AFTER_DATA 0x580 -#define A_DISCONNECT_DURING_DATA 0x780 -#define A_RESELECTION_IDENTIFIED 0x1003 -#define A_UNEXPECTED_PHASE 0x20 -#define A_FATAL 0x2000 -#define A_DEBUG_INTERRUPT 0x3000 - -/* SCSI Script execution states */ -#define SCRIPT_STATE_IDLE 0 -#define SCRIPT_STATE_SELECTING 1 -#define SCRIPT_STATE_COMMAND 2 -#define SCRIPT_STATE_DATA 3 -#define SCRIPT_STATE_STATUS 4 -#define SCRIPT_STATE_MESSAGE 5 -#define SCRIPT_STATE_DISCONNECTED 6 - -#define AFTER_SELECTION 0x100 -#define BEFORE_CMD 0x200 -#define AFTER_CMD 0x300 -#define AFTER_STATUS 0x400 -#define AFTER_DATA_IN 0x500 -#define AFTER_DATA_OUT 0x600 -#define DURING_DATA_IN 0x700 - -#define NOT_MSG_OUT 0x10 -#define UNEXPECTED_PHASE 0x20 -#define NOT_MSG_IN 0x30 -#define UNEXPECTED_MSG 0x40 -#define MSG_IN 0x50 -#define SDTR_MSG_R 0x60 -#define REJECT_MSG_R 0x70 -#define DISCONNECT 0x80 -#define MSG_OUT 0x90 -#define WDTR_MSG_R 0xA0 - -#define GOOD_STATUS 0x1 - -#define NOT_MSG_OUT_AFTER_SELECTION 0x110 -#define UNEXPECTED_PHASE_BEFORE_CMD 0x220 -#define UNEXPECTED_PHASE_AFTER_CMD 0x320 -#define NOT_MSG_IN_AFTER_STATUS 0x430 -#define GOOD_STATUS_AFTER_STATUS 0x401 -#define UNEXPECTED_PHASE_AFTER_DATA_IN 0x520 -#define UNEXPECTED_PHASE_AFTER_DATA_OUT 0x620 -#define UNEXPECTED_MSG_BEFORE_CMD 0x240 -#define MSG_IN_BEFORE_CMD 0x250 -#define MSG_IN_AFTER_CMD 0x350 -#define SDTR_MSG_BEFORE_CMD 0x260 -#define REJECT_MSG_BEFORE_CMD 0x270 -#define DISCONNECT_AFTER_CMD 0x380 -#define SDTR_MSG_AFTER_CMD 0x360 -#define WDTR_MSG_AFTER_CMD 0x3A0 -#define MSG_IN_AFTER_STATUS 0x440 -#define DISCONNECT_AFTER_DATA 0x580 -#define MSG_IN_AFTER_DATA_IN 0x550 -#define MSG_IN_AFTER_DATA_OUT 0x650 -#define MSG_OUT_AFTER_DATA_IN 0x590 -#define DATA_IN_AFTER_DATA_IN 0x5a0 -#define MSG_IN_DURING_DATA_IN 0x750 -#define DISCONNECT_DURING_DATA 0x780 - -#define RESELECTED_DURING_SELECTION 0x1000 -#define COMPLETED_SELECTION_AS_TARGET 0x1001 -#define RESELECTION_IDENTIFIED 0x1003 - -#define FATAL 0x2000 -#define FATAL_UNEXPECTED_RESELECTION_MSG 0x2000 -#define FATAL_SEND_MSG 0x2001 -#define FATAL_NOT_MSG_IN_AFTER_SELECTION 0x2002 -#define FATAL_ILLEGAL_MSG_LENGTH 0x2003 - -#define DEBUG_INTERRUPT 0x3000 -#define DEBUG_INTERRUPT1 0x3001 -#define DEBUG_INTERRUPT2 0x3002 -#define DEBUG_INTERRUPT3 0x3003 -#define DEBUG_INTERRUPT4 0x3004 -#define DEBUG_INTERRUPT5 0x3005 -#define DEBUG_INTERRUPT6 0x3006 - -#define COMMAND_COMPLETE_MSG 0x00 -#define EXTENDED_MSG 0x01 -#define SDTR_MSG 0x01 -#define SAVE_DATA_PTRS_MSG 0x02 -#define RESTORE_DATA_PTRS_MSG 0x03 -#define WDTR_MSG 0x03 -#define DISCONNECT_MSG 0x04 -#define REJECT_MSG 0x07 -#define PARITY_ERROR_MSG 0x09 -#define SIMPLE_TAG_MSG 0x20 -#define IDENTIFY_MSG 0x80 -#define IDENTIFY_MSG_MASK 0x7F -#define TWO_BYTE_MSG 0x20 -#define TWO_BYTE_MSG_MASK 0x0F - -/* SCSI phases */ -#define PHASE_DO 0 /* Data out phase */ -#define PHASE_DI 1 /* Data in phase */ -#define PHASE_CO 2 /* Command phase */ -#define PHASE_SI 3 /* Status phase */ -#define PHASE_ST 3 /* Status phase (alias) */ -#define PHASE_MO 6 /* Message out phase */ -#define PHASE_MI 7 /* Message in phase */ -#define PHASE_MASK 7 /* Mask for phase bits */ - -#define NCR710_TAG_VALID (1 << 16) - -static void ncr710_scsi_fifo_init(NCR710_SCSI_FIFO *fifo); -static const char *ncr710_reg_name(int offset); -static void ncr710_script_scsi_interrupt(NCR710State *s, int stat0); -static void ncr710_update_irq(NCR710State *s); -static void ncr710_script_dma_interrupt(NCR710State *s, int stat); -static void ncr710_request_free(NCR710State *s, NCR710Request *p); -static inline void ncr710_dma_read(NCR710State *s, uint32_t addr, - void *buf, uint32_t len); -static inline void ncr710_dma_write(NCR710State *s, uint32_t addr, - const void *buf, uint32_t len); -static uint8_t ncr710_reg_readb(NCR710State *s, int offset); -static void ncr710_reg_writeb(NCR710State *s, int offset, uint8_t val); - - -static inline int ncr710_irq_on_rsl(NCR710State *s) +static const char *lsi_reg_name(int offset) { - return (s->sien0 & NCR710_SSTAT0_SEL) !=3D 0; + return (offset >=3D 0 && offset < 64) ? lsi_reg_names[offset] : "???"; } =20 -static void ncr710_clear_pending_irq(NCR710State *s) +static uint8_t lsi_reg_readb(NCR710State *s, int offset); +static void lsi_reg_writeb(NCR710State *s, int offset, uint8_t val); +static void lsi_execute_script(NCR710State *s); +static void lsi_set_phase(NCR710State *s, int phase); + +/* + * On the 53C700 family the Select/Reselect destination ID and SDID are a = one + * hot bitmask, unlike the 53C8xx's binary target number. + */ +static int lsi_id_from_bits(unsigned bits) { - if (s->current) { - if (s->current->req) { - s->current->req->hba_private =3D NULL; + int i; + + bits &=3D 0xff; + for (i =3D 0; i < 8; i++) { + if (bits & (1u << i)) { + return i; } - ncr710_request_free(s, s->current); - s->current =3D NULL; } + qemu_log_mask(LOG_GUEST_ERROR, + "ncr710: empty destination ID bitmask; defaulting to ID = 0\n"); + return 0; } =20 void ncr710_soft_reset(NCR710State *s) { trace_ncr710_reset(); + s->carry =3D 0; - s->msg_action =3D NCR710_MSG_ACTION_NONE; + s->msg_action =3D LSI_MSG_ACTION_COMMAND; s->msg_len =3D 0; - s->waiting =3D NCR710_WAIT_NONE; - s->wait_reselect =3D false; - s->reselection_id =3D 0; - s->dsa =3D 0; - s->dnad =3D 0; - s->dbc =3D 0; - s->temp =3D 0; - s->scratch =3D 0; - s->istat &=3D 0x40; - s->dcmd =3D 0x40; - s->dstat =3D NCR710_DSTAT_DFE; - s->dien =3D 0x04; - s->sien0 =3D 0; - s->ctest2 =3D NCR710_CTEST2_DACK; - s->ctest3 =3D 0; - s->ctest4 =3D 0; - s->ctest5 =3D 0; - s->dsp =3D 0; - s->dsps =3D 0; - s->dmode &=3D NCR710_DMODE_FC1; - s->dcntl &=3D NCR710_DCNTL_EA; - s->scntl0 =3D 0xc0; + s->waiting =3D LSI_NOWAIT; + s->current_lun =3D 0; + s->select_tag =3D 0; + s->command_complete =3D 0; + s->script_running =3D false; + + s->scntl0 =3D 0xc0; /* full arbitration */ s->scntl1 =3D 0; + s->sdid =3D 0; + s->sien =3D 0; + s->scid =3D 0; + s->sxfer =3D 0; + s->sodl =3D 0; + s->socl =3D 0; + s->sfbr =3D 0; + s->sidl =3D 0; + s->sbdl =3D 0; + s->sbcl =3D 0; + s->dstat =3D 0; /* DFE is OR'd in on read */ s->sstat0 =3D 0; s->sstat1 =3D 0; s->sstat2 =3D 0; - s->scid =3D 0x80; - s->sxfer =3D 0; - s->socl =3D 0; - s->sdid =3D 0; - s->sbcl =3D 0; - s->sidl =3D 0; - s->sfbr =3D 0; - qemu_set_irq(s->irq, 0); - if (s->current && s->current->req) { - /* Drops hba_private via ncr710_request_cancelled() */ - scsi_req_cancel(s->current->req); - } - ncr710_clear_pending_irq(s); - ncr710_scsi_fifo_init(&s->scsi_fifo); -} + s->dsa =3D 0; + s->ctest0 =3D 0; + s->ctest3 =3D 0; + s->ctest4 =3D 0; + s->ctest5 =3D 0; + s->ctest7 =3D 0; + s->temp =3D 0; + s->dfifo =3D 0; + s->istat =3D 0; + s->lcrc =3D 0; + s->dbc =3D 0; + s->dcmd =3D 0; + s->dnad =3D 0; + s->dsp =3D 0; + s->dsps =3D 0; + s->scratch =3D 0; + s->dmode &=3D NCR710_DMODE_FC1; + s->dien =3D 0; + s->dwt =3D 0; + s->dcntl &=3D NCR710_DCNTL_EA; + s->adder =3D 0; =20 -static const char *ncr710_reg_name(int offset) -{ - switch (offset) { - case NCR710_SCNTL0_REG: return "SCNTL0"; - case NCR710_SCNTL1_REG: return "SCNTL1"; - case NCR710_SDID_REG: return "SDID"; - case NCR710_SIEN_REG: return "SIEN"; - case NCR710_SCID_REG: return "SCID"; - case NCR710_SXFER_REG: return "SXFER"; - case NCR710_SODL_REG: return "SODL"; - case NCR710_SOCL_REG: return "SOCL"; - case NCR710_SFBR_REG: return "SFBR"; - case NCR710_SIDL_REG: return "SIDL"; - case NCR710_SBDL_REG: return "SBDL"; - case NCR710_SBCL_REG: return "SBCL"; - case NCR710_DSTAT_REG: return "DSTAT"; - case NCR710_SSTAT0_REG: return "SSTAT0"; - case NCR710_SSTAT1_REG: return "SSTAT1"; - case NCR710_SSTAT2_REG: return "SSTAT2"; - case NCR710_DSA_REG: return "DSA"; - case NCR710_DSA_REG + 1: return "DSA+1"; - case NCR710_DSA_REG + 2: return "DSA+2"; - case NCR710_DSA_REG + 3: return "DSA+3"; - case NCR710_CTEST0_REG: return "CTEST0"; - case NCR710_CTEST1_REG: return "CTEST1"; - case NCR710_CTEST2_REG: return "CTEST2"; - case NCR710_CTEST3_REG: return "CTEST3"; - case NCR710_CTEST4_REG: return "CTEST4"; - case NCR710_CTEST5_REG: return "CTEST5"; - case NCR710_CTEST6_REG: return "CTEST6"; - case NCR710_CTEST7_REG: return "CTEST7"; - case NCR710_TEMP_REG: return "TEMP"; - case NCR710_TEMP_REG + 1: return "TEMP+1"; - case NCR710_TEMP_REG + 2: return "TEMP+2"; - case NCR710_TEMP_REG + 3: return "TEMP+3"; - case NCR710_DFIFO_REG: return "DFIFO"; - case NCR710_ISTAT_REG: return "ISTAT"; - case NCR710_CTEST8_REG: return "CTEST8"; - case NCR710_LCRC_REG: return "LCRC"; - case NCR710_DBC_REG: return "DBC"; - case NCR710_DBC_REG + 1: return "DBC+1"; - case NCR710_DBC_REG + 2: return "DBC+2"; - case NCR710_DCMD_REG: return "DCMD"; - case NCR710_DNAD_REG: return "DNAD"; - case NCR710_DNAD_REG + 1: return "DNAD+1"; - case NCR710_DNAD_REG + 2: return "DNAD+2"; - case NCR710_DNAD_REG + 3: return "DNAD+3"; - case NCR710_DSP_REG: return "DSP"; - case NCR710_DSP_REG + 1: return "DSP+1"; - case NCR710_DSP_REG + 2: return "DSP+2"; - case NCR710_DSP_REG + 3: return "DSP+3"; - case NCR710_DSPS_REG: return "DSPS"; - case NCR710_DSPS_REG + 1: return "DSPS+1"; - case NCR710_DSPS_REG + 2: return "DSPS+2"; - case NCR710_DSPS_REG + 3: return "DSPS+3"; - case NCR710_SCRATCH_REG: return "SCRATCH"; - case NCR710_SCRATCH_REG + 1: return "SCRATCH+1"; - case NCR710_SCRATCH_REG + 2: return "SCRATCH+2"; - case NCR710_SCRATCH_REG + 3: return "SCRATCH+3"; - case NCR710_DMODE_REG: return "DMODE"; - case NCR710_DIEN_REG: return "DIEN"; - case NCR710_DWT_REG: return "DWT"; - case NCR710_DCNTL_REG: return "DCNTL"; - case NCR710_ADDER_REG: return "ADDER"; - case NCR710_ADDER_REG + 1: return "ADDER+1"; - case NCR710_ADDER_REG + 2: return "ADDER+2"; - case NCR710_ADDER_REG + 3: return "ADDER+3"; - default: return "UNKNOWN"; + if (s->scripts_timer) { + timer_del(s->scripts_timer); } } =20 -static uint8_t ncr710_generate_scsi_parity(NCR710State *s, uint8_t data) +static inline void lsi_mem_read(NCR710State *s, uint32_t addr, + void *buf, uint32_t len) { - uint8_t parity =3D parity8(data); - - if (s->scntl1 & NCR710_SCNTL1_AESP) { - parity =3D !parity; - } - - return parity; + address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED, buf, len); } =20 -static bool ncr710_check_scsi_parity(NCR710State *s, uint8_t data, - uint8_t parity) +static inline void lsi_mem_write(NCR710State *s, uint32_t addr, + const void *buf, uint32_t len) { - if (!(s->scntl0 & NCR710_SCNTL0_EPC)) { - return true; - } - - uint8_t expected_parity =3D ncr710_generate_scsi_parity(s, data); - return parity =3D=3D expected_parity; + address_space_write(s->as, addr, MEMTXATTRS_UNSPECIFIED, buf, len); } =20 -static void ncr710_handle_parity_error(NCR710State *s) -{ - s->sstat0 |=3D NCR710_SSTAT0_PAR; - - /* If parity error ATN is enabled, assert ATN */ - if (s->scntl0 & NCR710_SCNTL0_AAP) { - s->socl |=3D NCR710_SOCL_ATN; - } - - ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_PAR); -} - -/* - * NCR710 SCSI FIFO IMPLEMENTATION - * - * Hardware Specifications (NCR53C710 datasheet): - * - Width: 9 bits (8 data bits + 1 parity bit) - * - Depth: 8 bytes - * - Type: Circular buffer - * - * Implementation: - * - Enqueue: Add byte at tail position ((head + count) % 8) - * - Dequeue: Remove byte from head position, advance head - * - Status: Empty (count=3D0), Full (count=3D8) - * - * FIFO Operations: - * - ncr710_scsi_fifo_init() - Reset FIFO to empty state - * - ncr710_scsi_fifo_enqueue() - Add byte with parity to tail - * - ncr710_scsi_fifo_dequeue() - Remove byte with parity from head - * - ncr710_scsi_fifo_empty() - Check if FIFO is empty - * - ncr710_scsi_fifo_full() - Check if FIFO is full - */ - -static void ncr710_scsi_fifo_init(NCR710_SCSI_FIFO *fifo) -{ - memset(fifo->data, 0, NCR710_SCSI_FIFO_SIZE); - memset(fifo->parity, 0, NCR710_SCSI_FIFO_SIZE); - fifo->head =3D 0; - fifo->count =3D 0; -} - -static inline bool ncr710_scsi_fifo_empty(NCR710_SCSI_FIFO *fifo) -{ - return fifo->count =3D=3D 0; -} - -static inline bool ncr710_scsi_fifo_full(NCR710_SCSI_FIFO *fifo) -{ - return fifo->count =3D=3D NCR710_SCSI_FIFO_SIZE; -} - -static inline int ncr710_scsi_fifo_enqueue(NCR710_SCSI_FIFO *fifo, - uint8_t data, uint8_t parity) -{ - if (ncr710_scsi_fifo_full(fifo)) { - return -1; /* FIFO full - 8 transfers deep */ - } - - /* Add data at the tail (head + count) */ - int tail_pos =3D (fifo->head + fifo->count) % NCR710_SCSI_FIFO_SIZE; - fifo->data[tail_pos] =3D data; - fifo->parity[tail_pos] =3D parity; - fifo->count++; - - return 0; -} - -static inline uint8_t ncr710_scsi_fifo_dequeue(NCR710_SCSI_FIFO *fifo, - uint8_t *parity) -{ - uint8_t data; - - if (ncr710_scsi_fifo_empty(fifo)) { - *parity =3D 0; - return 0; /* FIFO empty */ - } - - /* Taking data from the head position */ - data =3D fifo->data[fifo->head]; - *parity =3D fifo->parity[fifo->head]; - fifo->head =3D (fifo->head + 1) % NCR710_SCSI_FIFO_SIZE; - fifo->count--; - - return data; -} - -static inline uint32_t ncr710_read_dword(NCR710State *s, uint32_t addr) +/* SCRIPTS and table indirect structures are built by the big endian CPU. = */ +static inline uint32_t lsi_read_dword(NCR710State *s, uint32_t addr) { uint32_t buf; - address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED, - (uint8_t *)&buf, 4); - /* - * The NCR710 datasheet saying "operates internally in LE mode" - * refers to its internal register organization, - * not how it reads SCRIPTS from host memory. - */ - buf =3D be32_to_cpu(buf); - NCR710_DPRINTF("Read dword %08x from %08x\n", buf, addr); - return buf; + + address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED, &buf, 4); + return be32_to_cpu(buf); } =20 -static inline void ncr710_dma_read(NCR710State *s, uint32_t addr, - void *buf, uint32_t len) +static void lsi_stop_script(NCR710State *s) { - address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED, - buf, len); - NCR710_DPRINTF("Read %d bytes from %08x: ", len, addr); - for (int i =3D 0; i < len && i < 16; i++) { - NCR710_DPRINTF("%02x ", ((uint8_t *)buf)[i]); - } - NCR710_DPRINTF("\n"); + s->script_running =3D false; } =20 -static inline void ncr710_dma_write(NCR710State *s, uint32_t addr, - const void *buf, uint32_t len) -{ - address_space_write(s->as, addr, MEMTXATTRS_UNSPECIFIED, - buf, len); - NCR710_DPRINTF("Wrote %d bytes to %08x\n", len, addr); -} - -static void ncr710_stop_script(NCR710State *s) -{ - s->script_active =3D 0; - s->scntl1 &=3D ~NCR710_SCNTL1_CON; - s->istat &=3D ~NCR710_ISTAT_CON; -} - -static void ncr710_update_irq(NCR710State *s) +static void lsi_update_irq(NCR710State *s) { int level =3D 0; =20 - if (s->dstat & ~NCR710_DSTAT_DFE) { + if (s->dstat) { if (s->dstat & s->dien) { level =3D 1; } - s->istat |=3D NCR710_ISTAT_DIP; + s->istat |=3D LSI_ISTAT0_DIP; } else { - s->istat &=3D ~NCR710_ISTAT_DIP; + s->istat &=3D ~LSI_ISTAT0_DIP; } =20 if (s->sstat0) { - if ((s->sstat0 & s->sien0)) { + if (s->sstat0 & s->sien) { level =3D 1; } - s->istat |=3D NCR710_ISTAT_SIP; + s->istat |=3D LSI_ISTAT0_SIP; } else { - s->istat &=3D ~NCR710_ISTAT_SIP; + s->istat &=3D ~LSI_ISTAT0_SIP; } =20 + trace_ncr710_update_irq(level, s->istat, s->sstat0, s->dstat); qemu_set_irq(s->irq, level); } =20 -static void ncr710_script_scsi_interrupt(NCR710State *s, int stat0) +/* Raise a SCSI interrupt and stop SCRIPTS on a fatal/unmasked condition. = */ +static void lsi_script_scsi_interrupt(NCR710State *s, int stat0) { - uint32_t mask0; + uint8_t mask; =20 trace_ncr710_script_scsi_interrupt(stat0, s->sstat0); s->sstat0 |=3D stat0; - mask0 =3D stat0 & s->sien0; - if (mask0) { - ncr710_stop_script(s); - s->istat |=3D NCR710_ISTAT_SIP; - ncr710_update_irq(s); + /* + * FCMP and SEL are nonfatal (only stop when enabled in SIEN); STO nev= er + * stops here (execution continues until the next SCSI bus instruction= ). + */ + mask =3D s->sien | (uint8_t)~(LSI_STAT0_FCMP | LSI_STAT0_SEL); + mask &=3D ~LSI_STAT0_STO; + if (s->sstat0 & mask) { + lsi_stop_script(s); } + lsi_update_irq(s); } =20 -static void ncr710_script_dma_interrupt(NCR710State *s, int stat) +/* Raise a DMA interrupt and stop SCRIPTS (all DMA interrupts are fatal). = */ +static void lsi_script_dma_interrupt(NCR710State *s, int stat) { trace_ncr710_script_dma_interrupt(stat, s->dstat); - if (stat =3D=3D NCR710_DSTAT_SIR && (s->dstat & NCR710_DSTAT_DFE)) { - s->dstat &=3D ~NCR710_DSTAT_DFE; - } - s->dstat |=3D stat; - s->istat |=3D NCR710_ISTAT_DIP; - ncr710_update_irq(s); - ncr710_stop_script(s); + lsi_update_irq(s); + lsi_stop_script(s); } =20 -inline void ncr710_set_phase(NCR710State *s, int phase) +static void lsi_set_phase(NCR710State *s, int phase) { + trace_ncr710_set_phase(phase); + s->sbcl =3D (s->sbcl & ~PHASE_MASK) | phase | LSI_SBCL_REQ; s->sstat2 =3D (s->sstat2 & ~PHASE_MASK) | phase; - s->ctest0 &=3D ~1; - if (phase =3D=3D PHASE_DI) { - s->ctest0 |=3D 1; - } - s->sbcl &=3D ~NCR710_SBCL_REQ; } =20 -static void ncr710_disconnect(NCR710State *s) +/* 53C710 has no phase mismatch jump feature; a bad phase always interrupt= s. */ +static int lsi_bad_phase(NCR710State *s, int new_phase) +{ + lsi_script_scsi_interrupt(s, LSI_STAT0_MA); + lsi_stop_script(s); + lsi_set_phase(s, new_phase); + return 1; +} + +static void lsi_resume_script(NCR710State *s) +{ + trace_ncr710_resume_script(s->waiting); + if (s->waiting !=3D LSI_DMA_SCRIPTS) { + s->waiting =3D LSI_NOWAIT; + lsi_execute_script(s); + } else { + s->waiting =3D LSI_NOWAIT; + } +} + +static void lsi_disconnect(NCR710State *s) { trace_ncr710_disconnect(s->waiting); - if (s->waiting =3D=3D NCR710_WAIT_NONE) { - s->scntl1 &=3D ~NCR710_SCNTL1_CON; - s->istat &=3D ~NCR710_ISTAT_CON; - } + s->scntl1 &=3D ~LSI_SCNTL1_CON; s->sstat2 &=3D ~PHASE_MASK; + s->sbcl =3D 0; } =20 -static void ncr710_bad_selection(NCR710State *s, uint32_t id) +static void lsi_bad_selection(NCR710State *s, uint32_t id) { trace_ncr710_bad_selection(id); - s->dstat =3D 0; - s->dsps =3D 0; - ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_STO); - ncr710_disconnect(s); + lsi_script_scsi_interrupt(s, LSI_STAT0_STO); + lsi_disconnect(s); } =20 -static void ncr710_clear_selection_timeout(NCR710State *s) -{ - if (s->sstat0 & NCR710_SSTAT0_STO) { - s->sstat0 &=3D ~NCR710_SSTAT0_STO; - ncr710_clear_pending_irq(s); - if (s->sstat0 =3D=3D 0) { - s->istat &=3D ~NCR710_ISTAT_SIP; - } - ncr710_update_irq(s); - } -} - -static void ncr710_do_dma(NCR710State *s, int out) +static void lsi_do_dma(NCR710State *s, int out) { uint32_t count; uint32_t addr; - SCSIDevice *dev; - assert(s->current); - if (!s->current->dma_len) { - /* We wait until data is available. */ + SCSIRequest *req; + lsi_request *p; + + if (!s->current || !s->current->dma_len) { + /* Wait until data is available. */ + trace_ncr710_do_dma_unavailable(); return; } =20 - dev =3D s->current->req->dev; - assert(dev); + p =3D s->current; + req =3D scsi_req_ref(s->current->req); =20 count =3D s->dbc; - if (count > s->current->dma_len) { - count =3D s->current->dma_len; + if (count > p->dma_len) { + count =3D p->dma_len; } =20 addr =3D s->dnad; - + trace_ncr710_do_dma(addr, count); s->dnad +=3D count; s->dbc -=3D count; - if (s->current->dma_buf =3D=3D NULL) { - s->current->dma_buf =3D scsi_req_get_buf(s->current->req); + if (p->dma_buf =3D=3D NULL) { + p->dma_buf =3D scsi_req_get_buf(req); } - /* ??? Set SFBR to first data byte. */ if (out) { - ncr710_dma_read(s, addr, s->current->dma_buf, count); + lsi_mem_read(s, addr, p->dma_buf, count); } else { - ncr710_dma_write(s, addr, s->current->dma_buf, count); + lsi_mem_write(s, addr, p->dma_buf, count); } - s->current->dma_len -=3D count; - if (s->current->dma_len =3D=3D 0) { - s->current->dma_buf =3D NULL; - s->current->pending =3D 0; - s->waiting =3D NCR710_WAIT_DMA; - scsi_req_continue(s->current->req); + if (p->orphan) { + scsi_req_unref(req); return; + } + scsi_req_unref(req); + + p->dma_len -=3D count; + if (p->dma_len =3D=3D 0) { + p->dma_buf =3D NULL; + scsi_req_continue(req); } else { - s->current->dma_buf +=3D count; - s->waiting =3D NCR710_WAIT_NONE; - ncr710_execute_script(s); + p->dma_buf +=3D count; + lsi_resume_script(s); } } =20 -static void ncr710_add_msg_byte(NCR710State *s, uint8_t data) +static void lsi_add_msg_byte(NCR710State *s, uint8_t data) { - if (s->msg_len >=3D NCR710_MAX_MSGIN_LEN) { - BADF("MSG IN data too long\n"); + if (s->msg_len >=3D LSI_MAX_MSGIN_LEN) { + qemu_log_mask(LOG_GUEST_ERROR, "ncr710: MSG IN overflow\n"); } else { s->msg[s->msg_len++] =3D data; } } =20 -static void ncr710_request_free(NCR710State *s, NCR710Request *p) +/* + * Reselection-interrupt mode on the 53C700 family is enabled by SIEN.SEL = alone, + * with no separate SCID.RRE bit. With it clear, the driver instead parks= the + * SCRIPTS engine on a Wait Reselect instruction. + */ +static inline int lsi_irq_on_rsl(NCR710State *s) { - if (!p) { + return (s->sien & LSI_STAT0_SEL) !=3D 0; +} + +/* First disconnected request whose data the SCSI layer has made ready. */ +static lsi_request *lsi_get_pending_req(NCR710State *s) +{ + lsi_request *p; + + QTAILQ_FOREACH(p, &s->queue, next) { + if (p->pending) { + return p; + } + } + return NULL; +} + +/* Move the in-flight command to the disconnected queue (target disconnect= ). */ +static void lsi_queue_command(NCR710State *s) +{ + lsi_request *p =3D s->current; + + trace_ncr710_queue_command(p->tag); + assert(s->current !=3D NULL); + assert(s->current->dma_len =3D=3D 0); + QTAILQ_INSERT_TAIL(&s->queue, s->current, next); + s->current =3D NULL; + p->pending =3D 0; + p->out =3D (s->sstat2 & PHASE_MASK) =3D=3D PHASE_DO; +} + +/* Reselect a disconnected command to resume its data transfer. */ +static void lsi_reselect(NCR710State *s, lsi_request *p) +{ + int id; + + assert(s->current =3D=3D NULL); + QTAILQ_REMOVE(&s->queue, p, next); + s->current =3D p; + + id =3D (p->tag >> 8) & 0xf; + s->sdid =3D 1 << id; /* one-hot target id (53C700 fa= mily) */ + /* 53C700 compatibility: SFBR holds the reselecting id bitmask. */ + if (!(s->dcntl & LSI_DCNTL_COM)) { + s->sfbr =3D 1 << (id & 0x7); + } + trace_ncr710_reselect(id); + s->scntl1 |=3D LSI_SCNTL1_CON; + lsi_set_phase(s, PHASE_MI); + 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); /* IDENTIFY (reselection) */ + if (s->current->tag & LSI_TAG_VALID) { + lsi_add_msg_byte(s, 0x20); /* SIMPLE QUEUE TAG */ + lsi_add_msg_byte(s, p->tag & 0xff); + } + if (lsi_irq_on_rsl(s)) { + lsi_script_scsi_interrupt(s, LSI_STAT0_SEL); + } +} + +/* + * Record that the SCSI layer has data ready for a queued command. Return= s 0 if + * the device was reselected (the engine can continue), nonzero if the tra= nsfer + * is deferred until the engine next parks at Wait Reselect. + */ +static int lsi_queue_req(NCR710State *s, SCSIRequest *req, uint32_t len) +{ + lsi_request *p =3D req->hba_private; + + p->pending =3D len; + if (s->waiting =3D=3D LSI_WAIT_RESELECT || + (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) && + !(s->istat & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) { + lsi_reselect(s, p); + return 0; + } + trace_ncr710_queue_req(p->tag); + return 1; +} + +/* SCRIPTS Wait Reselect: reconnect a ready queued command, else park. */ +static void lsi_wait_reselect(NCR710State *s) +{ + lsi_request *p; + + if (s->current) { return; } - if (p->req && p->req->hba_private =3D=3D p) { - p->req->hba_private =3D NULL; + p =3D lsi_get_pending_req(s); + if (p) { + lsi_reselect(s, p); } + if (s->current =3D=3D NULL) { + s->waiting =3D LSI_WAIT_RESELECT; + } +} + +static void lsi_request_orphan(NCR710State *s, lsi_request *p) +{ + p->orphan =3D true; if (p =3D=3D s->current) { s->current =3D NULL; + } else { + QTAILQ_REMOVE(&s->queue, p, next); } - g_free(p); + scsi_req_unref(p->req); } =20 void ncr710_request_cancelled(SCSIRequest *req) { NCR710State *s =3D ncr710_from_scsi_bus(req->bus); - NCR710Request *p =3D (NCR710Request *)req->hba_private; - if (p) { - req->hba_private =3D NULL; - p->req =3D NULL; - ncr710_request_free(s, p); - } - scsi_req_unref(req); -} + lsi_request *p =3D req->hba_private; =20 -static int ncr710_queue_req(NCR710State *s, SCSIRequest *req, uint32_t len) -{ - NCR710Request *p =3D (NCR710Request *)req->hba_private; - - if (!p) { - return -1; - } - p->pending =3D len; - if ((s->waiting =3D=3D NCR710_WAIT_RESELECT && - !(s->istat & (NCR710_ISTAT_SIP | NCR710_ISTAT_DIP))) || - (ncr710_irq_on_rsl(s) && !(s->scntl1 & NCR710_SCNTL1_CON) && - !(s->istat & (NCR710_ISTAT_SIP | NCR710_ISTAT_DIP)))) { - s->current =3D p; - return 0; - } else { - s->current =3D p; - return 1; - } + lsi_request_orphan(s, p); } =20 void ncr710_command_complete(SCSIRequest *req, size_t resid) { NCR710State *s =3D ncr710_from_scsi_bus(req->bus); - NCR710Request *p =3D (NCR710Request *)req->hba_private; + int stop =3D 0; =20 trace_ncr710_command_complete(req->tag, req->status); - - s->lcrc =3D 0; s->status =3D req->status; - s->command_complete =3D NCR710_CMD_COMPLETE; - - if (p) { - p->pending =3D 0; - } - - ncr710_set_phase(s, PHASE_ST); - - if (p) { - req->hba_private =3D NULL; - if (p =3D=3D s->current) { - p->req =3D NULL; - } else { - ncr710_request_free(s, p); + s->command_complete =3D 2; + if (s->waiting && s->dbc !=3D 0) { + /* Raise phase mismatch for short transfers. */ + stop =3D lsi_bad_phase(s, PHASE_ST); + if (stop) { + s->waiting =3D LSI_NOWAIT; } - scsi_req_unref(req); + } else { + lsi_set_phase(s, PHASE_ST); } =20 - if (s->waiting =3D=3D NCR710_WAIT_RESELECT || s->waiting =3D=3D NCR710= _WAIT_DMA) { - s->waiting =3D NCR710_WAIT_NONE; - ncr710_execute_script(s); + if (req->hba_private =3D=3D s->current) { + lsi_request_orphan(s, s->current); + } + if (!stop) { + lsi_resume_script(s); } } =20 void ncr710_transfer_data(SCSIRequest *req, uint32_t len) { NCR710State *s =3D ncr710_from_scsi_bus(req->bus); + lsi_request *p =3D req->hba_private; + int out; =20 - assert(req->hba_private); + assert(!p->orphan); =20 - if (s->waiting =3D=3D NCR710_WAIT_DMA) { - NCR710Request *p =3D (NCR710Request *)req->hba_private; - if (p) { - p->dma_len =3D len; - } - s->dsp -=3D 8; - s->waiting =3D NCR710_WAIT_NONE; - ncr710_execute_script(s); - return; - } - - if (s->wait_reselect) { - s->current =3D (NCR710Request *)req->hba_private; - s->current->dma_len =3D len; - s->waiting =3D NCR710_WAIT_RESELECT; - } - - if (req->hba_private !=3D s->current || - (ncr710_irq_on_rsl(s) && !(s->scntl1 & NCR710_SCNTL1_CON)) || - s->waiting =3D=3D NCR710_WAIT_RESELECT) { - int queue_result =3D ncr710_queue_req(s, req, len); - if (queue_result !=3D 0) { + /* + * A disconnected command, or one whose data arrives while the engine = is + * parked at Wait Reselect, must reselect before its data can be moved. + */ + if (s->waiting =3D=3D LSI_WAIT_RESELECT || p !=3D s->current || + (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) { + if (lsi_queue_req(s, req, len)) { return; } } =20 - /* Host adapter (re)connected */ - s->command_complete =3D NCR710_CMD_DATA_READY; - if (!s->current) { - return; - } + out =3D (s->sstat2 & PHASE_MASK) =3D=3D PHASE_DO; + + trace_ncr710_transfer_data(req->tag, len); s->current->dma_len =3D len; - + s->command_complete =3D 1; if (s->waiting) { - s->scntl1 |=3D NCR710_SCNTL1_CON; - s->istat |=3D NCR710_ISTAT_CON; - s->sbcl =3D NCR710_SBCL_IO | NCR710_SBCL_CD | NCR710_SBCL_MSG | - NCR710_SBCL_BSY | NCR710_SBCL_SEL | NCR710_SBCL_REQ; - uint8_t host_id =3D (s->scid & 0x07); - - /* Special case: both target and host are ID 0 */ - if (req->dev->id =3D=3D 0 && host_id =3D=3D 0) { - s->sfbr =3D 0x00; + if (s->waiting =3D=3D LSI_WAIT_RESELECT || s->dbc =3D=3D 0) { + lsi_resume_script(s); } else { - s->sfbr =3D (req->dev->id =3D=3D 0 ? 0 : (1 << req->dev->id)) | - (host_id =3D=3D 0 ? 0 : (1 << host_id)); + lsi_do_dma(s, out); } - - ncr710_set_phase(s, PHASE_MI); - - if (s->current) { - uint8_t identify_msg =3D 0x80 | (req->lun & 0x07); - ncr710_add_msg_byte(s, identify_msg); - - if (s->current->tag) { - ncr710_add_msg_byte(s, 0x20); /* SIMPLE_TAG_MSG */ - ncr710_add_msg_byte(s, s->current->tag & 0xff); - } - } - - s->sstat0 |=3D NCR710_SSTAT0_SEL; - s->istat |=3D NCR710_ISTAT_SIP; - s->dsps =3D RESELECTED_DURING_SELECTION; - s->waiting =3D NCR710_WAIT_NONE; - ncr710_update_irq(s); - return; - } - if (!s->script_active && !s->waiting) { - ncr710_execute_script(s); } } =20 -static int idbitstonum(uint8_t id) -{ - return 7 - clz8(id); -} - -static void ncr710_do_command(NCR710State *s) +static void lsi_do_command(NCR710State *s) { SCSIDevice *dev; - uint8_t buf[16]; + uint8_t buf[16] =3D {0}; uint32_t id; int n; - int bytes_read; + if (s->dbc > 16) { s->dbc =3D 16; } - - /* - * Reading command data directly from memory - * NOTE: SCSI commands can be up to 16 bytes - * (e.g., READ_CAPACITY_10 is 10 bytes) but the NCR710 SCSI FIFO is - * only 8 bytes deep. For command phase, we bypass the FIFO and read - * directly from memory since commands don't need FIFO buffering. - */ - bytes_read =3D MIN(s->dbc, sizeof(buf)); - ncr710_dma_read(s, s->dnad, buf, bytes_read); - - s->dnad +=3D bytes_read; - s->dbc -=3D bytes_read; + lsi_mem_read(s, s->dnad, buf, s->dbc); s->sfbr =3D buf[0]; + s->command_complete =3D 0; + trace_ncr710_do_command(s->dbc, buf[0], + (buf[2] << 24) | (buf[3] << 16) | + (buf[4] << 8) | buf[5], + (buf[7] << 8) | buf[8]); =20 - s->command_complete =3D NCR710_CMD_PENDING; - id =3D (s->select_tag >> 8) & 0xff; - s->lcrc =3D id; - - dev =3D scsi_device_find(&s->bus, 0, idbitstonum(id), s->current_lun); - + id =3D (s->select_tag >> 8) & 0xf; + dev =3D scsi_device_find(&s->bus, 0, id, s->current_lun); if (!dev) { - ncr710_bad_selection(s, id); + lsi_bad_selection(s, id); return; } =20 - if (s->current) { - ncr710_request_free(s, s->current); - s->current =3D NULL; - } - - s->current =3D g_new0(NCR710Request, 1); + assert(s->current =3D=3D NULL); + s->current =3D g_new0(lsi_request, 1); s->current->tag =3D s->select_tag; - s->current->resume_offset =3D 0; - s->current->req =3D scsi_req_new(dev, s->current->tag, s->current_lun,= buf, - bytes_read, s->current); + s->dbc, s->current); + n =3D scsi_req_enqueue(s->current->req); if (n) { if (n > 0) { - ncr710_set_phase(s, PHASE_DI); + lsi_set_phase(s, PHASE_DI); } else if (n < 0) { - ncr710_set_phase(s, PHASE_DO); + lsi_set_phase(s, PHASE_DO); } scsi_req_continue(s->current->req); } - if (!s->command_complete) { - if (!n) { - ncr710_set_phase(s, PHASE_SI); + if (n) { + if ((s->current->tag & LSI_TAG_VALID) && + !lsi_irq_on_rsl(s)) { + /* + * Tagged command whose data is not yet ready, issued by a + * driver that parks the SCRIPTS engine on a Wait Reselect + * instruction (SIEN.SEL clear). Disconnect and queue it = so the + * bus is free for further tagged commands. Untagged tran= sfers + * and reselection-interrupt drivers stay connected. + */ + lsi_add_msg_byte(s, 2); /* SAVE DATA POINTER */ + lsi_add_msg_byte(s, 4); /* DISCONNECT */ + lsi_set_phase(s, PHASE_MI); + s->msg_action =3D LSI_MSG_ACTION_DISCONNECT; + lsi_queue_command(s); + } } else { - NCR710_DPRINTF("Data transfer phase\n"); + /* + * Async no data command. Park with dbc =3D 0 so the engine s= tops in + * COMMAND without a data phase. + */ + s->dbc =3D 0; + s->waiting =3D LSI_DMA_IN_PROGRESS; } } } =20 -static void ncr710_do_status(NCR710State *s) +static void lsi_do_status(NCR710State *s) { - uint8_t status =3D s->status; - uint8_t parity =3D 0; + uint8_t status; =20 + trace_ncr710_do_status(s->dbc, s->status); if (s->dbc !=3D 1) { - BADF("Bad Status move\n"); + qemu_log_mask(LOG_GUEST_ERROR, + "ncr710: STATUS move requested %u bytes (expected 1)= \n", + s->dbc); } s->dbc =3D 1; + status =3D s->status; s->sfbr =3D status; - - /* Generate parity if enabled and enqueue status byte */ - if (s->scntl0 & NCR710_SCNTL0_EPG) { - parity =3D ncr710_generate_scsi_parity(s, status); - } - ncr710_scsi_fifo_enqueue(&s->scsi_fifo, status, parity); - - /* Dequeue status byte and write to memory */ - status =3D ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity); - if (s->scntl0 & NCR710_SCNTL0_EPC) { - if (!ncr710_check_scsi_parity(s, status, parity)) { - ncr710_handle_parity_error(s); - } - } - ncr710_dma_write(s, s->dnad, &status, 1); - - s->dnad +=3D 1; - s->dbc -=3D 1; - - ncr710_set_phase(s, PHASE_MI); - s->msg_action =3D NCR710_MSG_ACTION_DISCONNECT; - ncr710_add_msg_byte(s, 0); /* COMMAND COMPLETE */ - s->command_complete =3D NCR710_CMD_COMPLETE; + lsi_mem_write(s, s->dnad, &status, 1); + lsi_set_phase(s, PHASE_MI); + s->msg_action =3D LSI_MSG_ACTION_DISCONNECT; + lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */ } =20 -static void ncr710_do_msgin(NCR710State *s) +static void lsi_do_msgin(NCR710State *s) { - int len; + uint8_t len; + + trace_ncr710_do_msgin(s->dbc, s->msg_len); + if (s->msg_len =3D=3D 0) { + /* + * MOVE WHEN MSG IN with no message queued: transfer nothing (SFBR + * keeps its last byte). After a declined negotiation MESSAGE REJ= ECT + * (msg_action COMMAND) the target switches to COMMAND. + */ + if (s->msg_action =3D=3D LSI_MSG_ACTION_COMMAND) { + lsi_set_phase(s, PHASE_CMD); + } + return; + } + s->sfbr =3D s->msg[0]; len =3D s->msg_len; + assert(len <=3D LSI_MAX_MSGIN_LEN); if (len > s->dbc) { len =3D s->dbc; } - s->sfbr =3D s->msg[0]; =20 - for (int i =3D 0; i < len; i++) { - uint8_t parity =3D 0; - if (s->scntl0 & NCR710_SCNTL0_EPG) { - parity =3D ncr710_generate_scsi_parity(s, s->msg[i]); - } - ncr710_scsi_fifo_enqueue(&s->scsi_fifo, s->msg[i], parity); - } - - uint8_t buf[NCR710_MAX_MSGIN_LEN]; - for (int i =3D 0; i < len; i++) { - uint8_t parity; - buf[i] =3D ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity); - if (s->scntl0 & NCR710_SCNTL0_EPC) { - if (!ncr710_check_scsi_parity(s, buf[i], parity)) { - ncr710_handle_parity_error(s); - } + if (len) { + lsi_mem_write(s, s->dnad, s->msg, len); + /* Drivers rely on the last byte being in SIDL. */ + s->sidl =3D s->msg[len - 1]; + s->msg_len -=3D len; + if (s->msg_len) { + memmove(s->msg, s->msg + len, s->msg_len); } } - ncr710_dma_write(s, s->dnad, buf, len); =20 - s->dnad +=3D len; - s->dbc -=3D len; - s->sidl =3D s->msg[len - 1]; - s->msg_len -=3D len; - if (s->msg_len) { - memmove(s->msg, s->msg + len, s->msg_len); - return; - } - switch (s->msg_action) { - case NCR710_MSG_ACTION_NONE: - ncr710_set_phase(s, PHASE_CO); - break; - case NCR710_MSG_ACTION_DISCONNECT: - s->sstat2 &=3D ~PHASE_MASK; - break; - case NCR710_MSG_ACTION_DATA_OUT: - ncr710_set_phase(s, PHASE_DO); - break; - case NCR710_MSG_ACTION_DATA_IN: - ncr710_set_phase(s, PHASE_DI); - break; - default: - abort(); + if (!s->msg_len) { + switch (s->msg_action) { + case LSI_MSG_ACTION_COMMAND: + /* Stay in MSG IN until the next block move requests COMMAND. = */ + break; + case LSI_MSG_ACTION_DISCONNECT: + lsi_disconnect(s); + break; + case LSI_MSG_ACTION_DOUT: + lsi_set_phase(s, PHASE_DO); + break; + case LSI_MSG_ACTION_DIN: + lsi_set_phase(s, PHASE_DI); + break; + default: + abort(); + } } } =20 -static void ncr710_do_msgout(NCR710State *s) +static uint8_t lsi_get_msgbyte(NCR710State *s) { - NCR710Request *current_req =3D s->current; + uint8_t data; =20 - while (s->dbc > 0) { - int to_move =3D MIN((int)s->dbc, NCR710_SCSI_FIFO_SIZE); - uint8_t temp_buf[NCR710_SCSI_FIFO_SIZE]; - ncr710_dma_read(s, s->dnad, temp_buf, to_move); - int filled =3D 0; - for (int j =3D 0; j < to_move && - !ncr710_scsi_fifo_full(&s->scsi_fifo); j++) { - uint8_t parity =3D 0; - if (s->scntl0 & NCR710_SCNTL0_EPG) { - parity =3D ncr710_generate_scsi_parity(s, temp_buf[j]); - } - if (ncr710_scsi_fifo_enqueue(&s->scsi_fifo, temp_buf[j], - parity) =3D=3D 0) { - filled++; - } else { - break; - } - } + lsi_mem_read(s, s->dnad, &data, 1); + s->dnad++; + s->dbc--; + return data; +} =20 - if (filled <=3D 0) { +static void lsi_skip_msgbytes(NCR710State *s, unsigned int n) +{ + s->dnad +=3D n; + s->dbc -=3D n; +} + +static void lsi_do_msgout(NCR710State *s) +{ + uint8_t msg; + + trace_ncr710_do_msgout(s->dbc); + while (s->dbc) { + msg =3D lsi_get_msgbyte(s); + s->sfbr =3D msg; + + switch (msg) { + case 0x04: + lsi_disconnect(s); break; - } - uint8_t buf[NCR710_SCSI_FIFO_SIZE]; - int bytes =3D 0; - for (int j =3D 0; j < filled && - !ncr710_scsi_fifo_empty(&s->scsi_fifo); j++) { - uint8_t parity; - buf[bytes] =3D ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity= ); - if (s->scntl0 & NCR710_SCNTL0_EPC) { - if (!ncr710_check_scsi_parity(s, buf[bytes], parity)) { - ncr710_handle_parity_error(s); - } - } - bytes++; - } - - s->dnad +=3D bytes; - s->dbc -=3D bytes; - int i =3D 0; - while (i < bytes) { - uint8_t msg =3D buf[i++]; - s->sfbr =3D msg; - + case 0x08: /* NOP */ + lsi_set_phase(s, PHASE_CMD); + break; + case 0x01: /* Extended message */ + lsi_get_msgbyte(s); /* skip the length byte */ + msg =3D lsi_get_msgbyte(s); switch (msg) { - case SCSI_MSG_COMMAND_COMPLETE: - /* 0x00 - NOP / padding byte / Command Complete */ - /* Just gonna ignore padding bytes, continue processing */ - break; - - case SCSI_MSG_DISCONNECT: /* 0x04 - Disconnect */ - ncr710_disconnect(s); - break; - - case SCSI_MSG_MESSAGE_REJECT: /* 0x07 - Message Reject */ - /* Target is rejecting our last message */ - ncr710_set_phase(s, PHASE_CO); - break; - - case SCSI_MSG_NO_OPERATION: /* 0x08 - NOP */ - ncr710_set_phase(s, PHASE_CO); - break; - - case SCSI_MSG_SAVE_DATA_POINTER: /* 0x02 - Save Data Pointer */ - /* Save current data pointer for later restore */ - break; - - case SCSI_MSG_RESTORE_POINTERS: /* 0x03 - Restore Pointers */ - /* Restore previously saved data pointer */ - break; - - case SCSI_MSG_EXTENDED_MESSAGE: { /* 0x01 - Extended message */ - if (i >=3D bytes) { - /* Not enough data; let next chunk continue parsing */ - i--; /* rewind one to reparse later */ - goto out_chunk; - } - i++; /* skip ext_len */ - - if (i >=3D bytes) { - i -=3D 2; /* rewind msg + ext_len for next chunk */ - goto out_chunk; - } - uint8_t ext_code =3D buf[i++]; - - switch (ext_code) { - case 1: /* SDTR (ignore body) */ - /* Body has 2 bytes, may span chunks: skip what we hav= e */ - { - int skip =3D MIN(2, bytes - i); - i +=3D skip; - /* - * If not all skipped this chunk, rest will arrive - * in next loop - */ - } - break; - case 3: /* WDTR (ignore body) */ - if (i < bytes) { - i++; /* skip one param byte if present this chunk = */ - } - break; - default: - goto bad; - } - break; - } - - case 0x20: /* SIMPLE queue tag */ - case 0x21: /* HEAD of queue tag */ - case 0x22: /* ORDERED queue tag */ - if (i < bytes) { - uint8_t tag =3D buf[i++]; - s->select_tag =3D (s->select_tag & 0xFF00) | tag | - NCR710_TAG_VALID; - NCR710_DPRINTF("Tagged command: tag=3D0x%02x, " - "type=3D0x%02x\n", tag, msg); - } else { - /* - * Tag byte not in this chunk; rewind and reparse - * next loop - */ - i--; - goto out_chunk; - } - break; - - case 0x0d: /* ABORT TAG */ - if (current_req) { - scsi_req_cancel(current_req->req); - } - ncr710_disconnect(s); - break; - - case SCSI_MSG_ABORT: /* 0x06 - ABORT */ - case 0x0e: /* CLEAR QUEUE */ - case SCSI_MSG_BUS_DEVICE_RESET: /* 0x0c - BUS DEVICE RESET */ - if (s->current) { - scsi_req_cancel(s->current->req); - } - ncr710_disconnect(s); - break; - + case 1: /* SDTR */ + lsi_skip_msgbytes(s, 2); + goto reject; + case 3: /* WDTR */ + lsi_skip_msgbytes(s, 1); + goto reject; + case 4: /* PPR */ + lsi_skip_msgbytes(s, 5); + goto reject; default: - if (msg & SCSI_MSG_IDENTIFY) { - uint8_t lun =3D msg & 0x07; - s->current_lun =3D lun; - ncr710_set_phase(s, PHASE_CO); - break; - } - - /* Unknown message - reject it */ goto bad; } + break; + case 0x20: /* SIMPLE queue tag */ + s->select_tag &=3D ~0xff; + s->select_tag |=3D lsi_get_msgbyte(s) | LSI_TAG_VALID; + break; + case 0x21: /* HEAD of queue tag */ + case 0x22: /* ORDERED queue tag */ + s->select_tag &=3D ~0xff; + s->select_tag |=3D lsi_get_msgbyte(s) | LSI_TAG_VALID; + break; + case 0x0d: /* ABORT TAG */ + case 0x06: /* ABORT */ + case 0x0e: /* CLEAR QUEUE */ + case 0x0c: /* BUS DEVICE RESET */ + if (s->current && s->current->req) { + scsi_req_cancel(s->current->req); + } + lsi_disconnect(s); + break; + default: + if ((msg & 0x80) =3D=3D 0) { + goto bad; + } + s->current_lun =3D msg & 7; /* IDENTIFY */ + lsi_set_phase(s, PHASE_CMD); + break; } - -out_chunk: - continue; } - return; - +reject: + /* Decline SDTR/WDTR/PPR negotiation with a single MESSAGE REJECT. */ + lsi_set_phase(s, PHASE_MI); + lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */ + s->msg_action =3D LSI_MSG_ACTION_COMMAND; + return; bad: - BADF("Unimplemented/Invalid message 0x%02x\n", s->sfbr); - ncr710_set_phase(s, PHASE_MI); - ncr710_add_msg_byte(s, 7); - s->msg_action =3D NCR710_MSG_ACTION_NONE; + qemu_log_mask(LOG_UNIMP, "ncr710: unimplemented message 0x%02x\n", msg= ); + lsi_set_phase(s, PHASE_MI); + lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */ + s->msg_action =3D LSI_MSG_ACTION_COMMAND; } =20 -static void ncr710_memcpy(NCR710State *s, uint32_t dest, uint32_t src, - int count) +static void lsi_memcpy(NCR710State *s, uint32_t dest, uint32_t src, int co= unt) { - uint8_t buf[NCR710_BUF_SIZE]; + QEMU_UNINITIALIZED uint8_t buf[LSI_BUF_SIZE]; + int n; =20 while (count) { - int chunk =3D MIN(count, NCR710_BUF_SIZE); - /* Read from source */ - ncr710_dma_read(s, src, buf, chunk); - - /* Write to destination */ - ncr710_dma_write(s, dest, buf, chunk); - - src +=3D chunk; - dest +=3D chunk; - count -=3D chunk; + n =3D (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count; + lsi_mem_read(s, src, buf, n); + lsi_mem_write(s, dest, buf, n); + src +=3D n; + dest +=3D n; + count -=3D n; } } =20 -static void ncr710_wait_reselect(NCR710State *s) +static void lsi_scripts_timer_start(NCR710State *s) { - s->wait_reselect =3D true; - s->waiting =3D NCR710_WAIT_RESELECT; - s->script_active =3D false; - - s->scntl1 &=3D ~NCR710_SCNTL1_CON; - s->istat &=3D ~NCR710_ISTAT_CON; + /* The wrapper allocates this timer on the nanosecond clock. */ + timer_mod(s->scripts_timer, + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 500000); } =20 -void ncr710_reselection_retry_callback(void *opaque) +void ncr710_scripts_timer_callback(void *opaque) { NCR710State *s =3D opaque; =20 - if (!s->current || s->current->pending =3D=3D 0) { - return; - } - - if (s->waiting !=3D NCR710_WAIT_RESELECT) { - return; - } - - if (s->istat & (NCR710_ISTAT_SIP | NCR710_ISTAT_DIP)) { - timer_mod(s->reselection_retry_timer, - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1000); - return; - } - - NCR710Request *p =3D s->current; - uint32_t len =3D p->pending; - p->pending =3D 0; - - SCSIRequest *req =3D p->req; - s->command_complete =3D NCR710_CMD_PENDING; - p->dma_len =3D len; - - s->scntl1 |=3D NCR710_SCNTL1_CON; - s->istat |=3D NCR710_ISTAT_CON; - s->sbcl =3D NCR710_SBCL_IO | NCR710_SBCL_CD | NCR710_SBCL_MSG | - NCR710_SBCL_BSY | NCR710_SBCL_SEL | NCR710_SBCL_REQ; - - uint8_t host_id =3D (s->scid & 0x07); - if (req->dev->id =3D=3D 0 && host_id =3D=3D 0) { - s->sfbr =3D 0x00; - } else { - s->sfbr =3D (req->dev->id =3D=3D 0 ? 0 : (1 << req->dev->id)) | - (host_id =3D=3D 0 ? 0 : (1 << host_id)); - } - - ncr710_set_phase(s, PHASE_MI); - - uint8_t identify_msg =3D 0x80 | (req->lun & 0x07); - ncr710_add_msg_byte(s, identify_msg); - - if (p->tag) { - ncr710_add_msg_byte(s, 0x20); /* SIMPLE_TAG_MSG */ - ncr710_add_msg_byte(s, p->tag & 0xff); - } - - s->dsp =3D p->resume_offset - 8; - - s->dsps =3D RESELECTED_DURING_SELECTION; - s->sstat0 |=3D NCR710_SSTAT0_SEL; - s->istat |=3D NCR710_ISTAT_SIP; - ncr710_update_irq(s); - s->waiting =3D NCR710_WAIT_NONE; + s->waiting =3D LSI_NOWAIT; + lsi_execute_script(s); } =20 -void ncr710_execute_script(NCR710State *s) +static void lsi_execute_script(NCR710State *s) { uint32_t insn; uint32_t addr; int opcode; - s->script_active =3D 1; + int insn_processed =3D 0; =20 + if (s->waiting =3D=3D LSI_WAIT_SCRIPTS) { + timer_del(s->scripts_timer); + s->waiting =3D LSI_NOWAIT; + } + + s->script_running =3D true; again: - insn =3D ncr710_read_dword(s, s->dsp); + /* Yield to the CPU after LSI_MAX_INSN instructions. */ + if (++insn_processed > LSI_MAX_INSN) { + trace_ncr710_script_yield(insn_processed); + s->waiting =3D LSI_WAIT_SCRIPTS; + lsi_scripts_timer_start(s); + return; + } + + insn =3D lsi_read_dword(s, s->dsp); if (!insn) { - /* - * If we receive an empty opcode increment the DSP by 4 bytes - * and execute the next opcode at that location - */ + /* Skip an empty (NULL) opcode 4 bytes at a time. */ s->dsp +=3D 4; goto again; } - addr =3D ncr710_read_dword(s, s->dsp + 4); + addr =3D lsi_read_dword(s, s->dsp + 4); + trace_ncr710_execute_script(s->dsp, insn, addr); s->dsps =3D addr; s->dcmd =3D insn >> 24; s->dsp +=3D 8; + switch (insn >> 30) { - case 0: /* Block move. */ - if (s->sstat0 & NCR710_SSTAT0_STO) { - NCR710_DPRINTF("Delayed select timeout\n"); - ncr710_stop_script(s); - ncr710_update_irq(s); + case 0: /* Block move */ + if (s->sstat0 & LSI_STAT0_STO) { + lsi_stop_script(s); break; } s->dbc =3D insn & 0xffffff; if (insn & (1 << 29)) { - /* Indirect addressing. */ - addr =3D ncr710_read_dword(s, addr); + /* Indirect addressing. */ + addr =3D lsi_read_dword(s, addr); } else if (insn & (1 << 28)) { + /* Table indirect addressing (32 bit). */ uint32_t buf[2]; - int32_t offset; - /* Table indirect addressing. */ + int32_t offset =3D sextract32(addr, 0, 24); =20 - /* 32-bit Table indirect */ - offset =3D sextract32(addr, 0, 24); - ncr710_dma_read(s, s->dsa + offset, buf, 8); - /* byte count is stored in bits 0:23 only */ + lsi_mem_read(s, s->dsa + offset, buf, 8); s->dbc =3D be32_to_cpu(buf[0]) & 0xffffff; addr =3D be32_to_cpu(buf[1]); } - /* Check phase match for block move instructions */ if ((s->sstat2 & PHASE_MASK) !=3D ((insn >> 24) & 7)) { - uint8_t current_phase =3D s->sstat2 & PHASE_MASK; - - ncr710_set_phase(s, current_phase); - s->sbcl |=3D NCR710_SBCL_REQ; - ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_MA); - ncr710_stop_script(s); - break; + /* + * The target controls the phase. The one legitimate lazy + * transition is MSG IN -> COMMAND after a declined negotiation + * MESSAGE REJECT. Any other requested phase is a mismatch. + */ + if ((s->sstat2 & PHASE_MASK) =3D=3D PHASE_MI && s->msg_len =3D= =3D 0 && + s->msg_action =3D=3D LSI_MSG_ACTION_COMMAND && + ((insn >> 24) & 7) =3D=3D PHASE_CMD) { + lsi_set_phase(s, PHASE_CMD); + } else { + trace_ncr710_block_move_badphase(s->sstat2 & PHASE_MASK, + (insn >> 24) & 7); + lsi_script_scsi_interrupt(s, LSI_STAT0_MA); + break; + } } - s->dnad =3D addr; - switch (s->sstat2 & 0x7) { + switch (s->sstat2 & PHASE_MASK) { case PHASE_DO: - s->waiting =3D NCR710_WAIT_DMA; - ncr710_do_dma(s, 1); + s->waiting =3D LSI_DMA_SCRIPTS; + lsi_do_dma(s, 1); + if (s->waiting) { + s->waiting =3D LSI_DMA_IN_PROGRESS; + } break; case PHASE_DI: - s->waiting =3D NCR710_WAIT_DMA; - ncr710_do_dma(s, 0); + s->waiting =3D LSI_DMA_SCRIPTS; + lsi_do_dma(s, 0); + if (s->waiting) { + s->waiting =3D LSI_DMA_IN_PROGRESS; + } break; - case PHASE_CO: - ncr710_do_command(s); + case PHASE_CMD: + lsi_do_command(s); break; - case PHASE_SI: - ncr710_do_status(s); + case PHASE_ST: + lsi_do_status(s); break; case PHASE_MO: - ncr710_do_msgout(s); + lsi_do_msgout(s); break; case PHASE_MI: - ncr710_do_msgin(s); + lsi_do_msgin(s); break; default: - BADF("Unimplemented phase %d\n", s->sstat2 & PHASE_MASK); + qemu_log_mask(LOG_UNIMP, "ncr710: unimplemented phase %d\n", + s->sstat2 & PHASE_MASK); } - s->ctest5 =3D (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3); + s->dfifo =3D s->dbc & 0x7f; break; =20 - case 1: /* IO or Read/Write instruction. */ + case 1: /* I/O or Read/Write register */ opcode =3D (insn >> 27) & 7; if (opcode < 5) { uint32_t id; + unsigned id_bits; =20 if (insn & (1 << 25)) { - id =3D ncr710_read_dword(s, s->dsa + sextract32(insn, 0, 2= 4)); + id_bits =3D lsi_read_dword(s, s->dsa + sextract32(insn, 0,= 24)); } else { - id =3D insn; + id_bits =3D insn; } - id =3D (id >> 16) & 0xff; + /* Destination ID is a one hot bitmask in bits 23:16. */ + id_bits =3D (id_bits >> 16) & 0xff; + id =3D lsi_id_from_bits(id_bits); if (insn & (1 << 26)) { addr =3D s->dsp + sextract32(addr, 0, 24); } s->dnad =3D addr; switch (opcode) { case 0: /* Select */ - s->sdid =3D id; - if (s->scntl1 & NCR710_SCNTL1_CON) { - if (!(insn & (1 << 24))) { - s->dsp =3D s->dnad; - break; - } - } - bool device_exists =3D false; - if (insn & (1 << 24)) { - /* ATN set - scan all LUNs for this target */ - for (int lun =3D 0; lun < 8; lun++) { - SCSIDevice *dev =3D scsi_device_find(&s->bus, 0, - idbitstonum(id), - lun); - if (dev) { - device_exists =3D true; - break; - } - } - } else { - /* No ATN - check only LUN 0 */ - SCSIDevice *dev =3D scsi_device_find(&s->bus, 0, - idbitstonum(id), 0); - device_exists =3D dev !=3D NULL; - } - if (!device_exists) { - ncr710_bad_selection(s, id); - if (!(insn & (1 << 24)) && addr !=3D 0) { - s->dsp =3D addr; - } + trace_ncr710_select(id, !!(insn & (1 << 24))); + s->sdid =3D id_bits; + if (s->scntl1 & LSI_SCNTL1_CON) { + s->dsp =3D s->dnad; break; - } else { - /* - * ??? Linux drivers compain when this is set. Maybe - * it only applies in low-level mode (unimplemented). - * ncr710_script_scsi_interrupt(s, NCR710_SIST0_CMP, 0= ); - */ - s->select_tag =3D id << 8; - s->scntl1 |=3D NCR710_SCNTL1_CON; - - if (insn & (1 << 24)) { - s->socl |=3D NCR710_SOCL_ATN; - ncr710_set_phase(s, PHASE_MO); - } else { - ncr710_set_phase(s, PHASE_CO); - } } + s->sstat1 |=3D 0x04; /* Won arbitration */ + if (!scsi_device_find(&s->bus, 0, id, 0)) { + lsi_bad_selection(s, id); + break; + } + s->select_tag =3D id << 8; + s->scntl1 |=3D LSI_SCNTL1_CON; + s->sbcl |=3D LSI_SBCL_BSY; + if (insn & (1 << 24)) { + /* Select with ATN/: the first phase is MESSAGE OUT. */ + s->socl |=3D LSI_SOCL_ATN; + s->sbcl |=3D LSI_SBCL_ATN; + lsi_set_phase(s, PHASE_MO); + } else { + /* No ATN/: target goes straight to COMMAND phase. */ + lsi_set_phase(s, PHASE_CMD); + } + s->waiting =3D LSI_NOWAIT; break; - case 1: /* Disconnect */ - - if (s->command_complete !=3D NCR710_CMD_PENDING) { - s->scntl1 &=3D ~NCR710_SCNTL1_CON; - s->istat &=3D ~NCR710_ISTAT_CON; - s->waiting =3D NCR710_WAIT_NONE; - } else { - if (s->current) { - s->current->resume_offset =3D s->dsp; - } - - s->waiting =3D NCR710_WAIT_RESELECT; - ncr710_stop_script(s); - NCR710_DPRINTF("SCRIPTS paused at WAIT DISCONNECT\n"); - } + case 1: /* Wait Disconnect */ + trace_ncr710_wait_disconnect(); + s->scntl1 &=3D ~LSI_SCNTL1_CON; break; case 2: /* Wait Reselect */ - if (!ncr710_irq_on_rsl(s)) { - ncr710_wait_reselect(s); + /* + * Two things release a Wait Reselect: SIGP (jump to the + * dispatch address latched in DNAD), or a disconnected co= mmand + * becoming ready to reselect. + */ + if (s->istat & LSI_ISTAT0_SIGP) { + /* + * The SIGP divert is a one-shot: clear the latch so a + * later Wait Reselect does not re-fire on a stale SIG= P. + * An active SIGP at reselection also disables target-= mode + * auto-switching. + */ + s->istat &=3D ~LSI_ISTAT0_SIGP; + s->dsp =3D s->dnad; + } else if (!lsi_irq_on_rsl(s)) { + lsi_wait_reselect(s); } break; case 3: /* Set */ if (insn & (1 << 3)) { - s->socl |=3D NCR710_SOCL_ATN; - ncr710_set_phase(s, PHASE_MO); + s->socl |=3D LSI_SOCL_ATN; + s->sbcl |=3D LSI_SBCL_ATN; + lsi_set_phase(s, PHASE_MO); + } + if (insn & (1 << 6)) { + s->sbcl |=3D LSI_SBCL_ACK; } if (insn & (1 << 10)) { s->carry =3D 1; @@ -1499,7 +960,11 @@ again: break; case 4: /* Clear */ if (insn & (1 << 3)) { - s->socl &=3D ~NCR710_SOCL_ATN; + s->socl &=3D ~LSI_SOCL_ATN; + s->sbcl &=3D ~LSI_SBCL_ATN; + } + if (insn & (1 << 6)) { + s->sbcl &=3D ~LSI_SBCL_ACK; } if (insn & (1 << 10)) { s->carry =3D 0; @@ -1507,31 +972,31 @@ again: break; } } else { - uint8_t op0; - uint8_t op1; - uint8_t data8; - int reg; - int xoperator; + /* + * Read/Write register. The 895a ALU operator encoding is a + * backward compatible superset of the 710's, so this decode is + * shared with lsi53c895a. + */ + uint8_t op0 =3D 0; + uint8_t op1 =3D 0; + uint8_t data8 =3D (insn >> 8) & 0xff; + int reg =3D ((insn >> 16) & 0x7f) | (insn & 0x80); + int operator =3D (insn >> 24) & 7; =20 - reg =3D ((insn >> 16) & 0x7f) | (insn & 0x80); - data8 =3D (insn >> 8) & 0xff; - opcode =3D (insn >> 27) & 7; - xoperator =3D (insn >> 24) & 7; - op0 =3D op1 =3D 0; switch (opcode) { case 5: /* From SFBR */ op0 =3D s->sfbr; op1 =3D data8; break; case 6: /* To SFBR */ - if (xoperator) { - op0 =3D ncr710_reg_readb(s, reg); + if (operator) { + op0 =3D lsi_reg_readb(s, reg); } op1 =3D data8; break; - case 7: /* Read-modify-write */ - if (xoperator) { - op0 =3D ncr710_reg_readb(s, reg); + case 7: /* Read modify write */ + if (operator) { + op0 =3D lsi_reg_readb(s, reg); } if (insn & (1 << 23)) { op1 =3D s->sfbr; @@ -1541,11 +1006,11 @@ again: break; } =20 - switch (xoperator) { + switch (operator) { case 0: /* move */ op0 =3D op1; break; - case 1: /* Shift left */ + case 1: /* shift left */ op1 =3D op0 >> 7; op0 =3D (op0 << 1) | s->carry; s->carry =3D op1; @@ -1559,7 +1024,7 @@ again: case 4: /* AND */ op0 &=3D op1; break; - case 5: /* SHR */ + case 5: /* shift right */ op1 =3D op0 & 1; op0 =3D (op0 >> 1) | (s->carry << 7); s->carry =3D op1; @@ -1580,8 +1045,8 @@ again: =20 switch (opcode) { case 5: /* From SFBR */ - case 7: /* Read-modify-write */ - ncr710_reg_writeb(s, reg, op0); + case 7: /* Read modify write */ + lsi_reg_writeb(s, reg, op0); break; case 6: /* To SFBR */ s->sfbr =3D op0; @@ -1590,13 +1055,17 @@ again: } break; =20 - case 2: /* Transfer Control. */ + case 2: /* Transfer Control */ { int cond; int jmp; =20 - - if (s->sstat0 & NCR710_SSTAT0_STO) { + if ((insn & 0x002e0000) =3D=3D 0) { + /* NOP */ + break; + } + if (s->sstat0 & LSI_STAT0_STO) { + lsi_stop_script(s); break; } cond =3D jmp =3D (insn & (1 << 19)) !=3D 0; @@ -1607,711 +1076,470 @@ again: cond =3D (s->sstat2 & PHASE_MASK) =3D=3D ((insn >> 24) & 7= ); } if (cond =3D=3D jmp && (insn & (1 << 18))) { - uint8_t mask; - - mask =3D (~insn >> 8) & 0xff; + uint8_t mask =3D (~insn >> 8) & 0xff; cond =3D (s->sfbr & mask) =3D=3D (insn & mask); } if (cond =3D=3D jmp) { if (insn & (1 << 23)) { - /* Relative address. */ + /* Relative address. */ addr =3D s->dsp + sextract32(addr, 0, 24); } switch ((insn >> 27) & 7) { case 0: /* Jump */ + trace_ncr710_tc_jump(addr); + s->adder =3D addr; s->dsp =3D addr; break; case 1: /* Call */ + trace_ncr710_tc_call(addr); s->temp =3D s->dsp; s->dsp =3D addr; break; case 2: /* Return */ - if (s->temp =3D=3D 0) { - ncr710_script_dma_interrupt(s, NCR710_DSTAT_IID); - break; - } + trace_ncr710_tc_return(s->temp); s->dsp =3D s->temp; break; case 3: /* Interrupt */ - if ((insn & (1 << 20)) !=3D 0) { - ncr710_update_irq(s); - } else { - if (s->dsps =3D=3D GOOD_STATUS_AFTER_STATUS) { - NCR710_DPRINTF("Script completion: Processing " - "GOOD_STATUS_AFTER_STATUS\n"); - NCR710_DPRINTF("Script completion: Command sta= te " - "preserved for driver processin= g\n"); - ncr710_script_dma_interrupt(s, - NCR710_DSTAT_SIR); - s->command_complete =3D NCR710_CMD_PENDING; - } else { - ncr710_script_dma_interrupt(s, NCR710_DSTAT_SI= R); - } - } + trace_ncr710_interrupt_insn(s->dsps); + lsi_script_dma_interrupt(s, LSI_DSTAT_SIR); break; default: - ncr710_script_dma_interrupt(s, NCR710_DSTAT_IID); + trace_ncr710_illegal_insn(insn); + lsi_script_dma_interrupt(s, LSI_DSTAT_IID); break; } } } break; =20 - case 3: + case 3: /* Memory Move (Load/Store is illegal on the 710) */ if ((insn & (1 << 29)) =3D=3D 0) { - /* Memory move. */ uint32_t dest; - /* - * ??? The docs imply the destination address is loaded into - * the TEMP register. However the Linux drivers rely on - * the value being preserved. - */ - dest =3D ncr710_read_dword(s, s->dsp); + + dest =3D lsi_read_dword(s, s->dsp); s->dsp +=3D 4; - ncr710_memcpy(s, dest, addr, insn & 0xffffff); + trace_ncr710_memmove(dest, addr, insn & 0xffffff); + lsi_memcpy(s, dest, addr, insn & 0xffffff); } else { - uint8_t data[8]; - int reg; - int n; - int i; - bool dsa_relative =3D (insn & (1 << 28)) !=3D 0; - bool is_load =3D (insn & (1 << 24)) !=3D 0; - - if (dsa_relative) { - addr =3D s->dsa + sextract32(addr, 0, 24); - } - - n =3D (insn & 7); - if (n =3D=3D 0) { - n =3D 8; /* 0 means 8 bytes */ - } - - reg =3D (insn >> 16) & 0xff; - - if (is_load) { - ncr710_dma_read(s, addr, data, n); - for (i =3D 0; i < n; i++) { - ncr710_reg_writeb(s, reg + i, data[i]); - } - } else { - for (i =3D 0; i < n; i++) { - data[i] =3D ncr710_reg_readb(s, reg + i); - } - ncr710_dma_write(s, addr, data, n); - } + trace_ncr710_illegal_insn(insn); + lsi_script_dma_interrupt(s, LSI_DSTAT_IID); } + break; } =20 - if (s->script_active && s->waiting =3D=3D NCR710_WAIT_NONE) { - if (s->dcntl & NCR710_DCNTL_SSM) { - ncr710_script_dma_interrupt(s, NCR710_DSTAT_SSI); - return; + if (s->script_running && s->waiting =3D=3D LSI_NOWAIT) { + if (s->dcntl & LSI_DCNTL_SSM) { + lsi_script_dma_interrupt(s, LSI_DSTAT_SSI); } else { goto again; } - } else if (s->waiting =3D=3D NCR710_WAIT_RESELECT) { - return; - } else if (s->waiting =3D=3D NCR710_WAIT_DMA || - s->waiting =3D=3D NCR710_WAIT_RESERVED) { - if (s->command_complete =3D=3D NCR710_CMD_COMPLETE) { - s->waiting =3D NCR710_WAIT_NONE; - goto again; - } - return; } } =20 -static uint8_t ncr710_reg_readb(NCR710State *s, int offset) +static uint8_t lsi_reg_readb(NCR710State *s, int offset) { - uint8_t ret =3D 0; - -#define CASE_GET_REG24(name, addr) \ - case addr: \ - ret =3D s->name & 0xff; \ - break; \ - case addr + 1: \ - ret =3D (s->name >> 8) & 0xff; \ - break; \ - case addr + 2: \ - ret =3D (s->name >> 16) & 0xff; \ - break; - -#define CASE_GET_REG32(name, addr) \ - case addr: \ - ret =3D s->name & 0xff; \ - break; \ - case addr + 1: \ - ret =3D (s->name >> 8) & 0xff; \ - break; \ - case addr + 2: \ - ret =3D (s->name >> 16) & 0xff; \ - break; \ - case addr + 3: \ - ret =3D (s->name >> 24) & 0xff; \ - break; + uint8_t ret; =20 switch (offset) { - case NCR710_SCNTL0_REG: /* SCNTL0 */ + case NCR710_SCNTL0: ret =3D s->scntl0; break; - case NCR710_SCNTL1_REG: /* SCNTL1 */ + case NCR710_SCNTL1: ret =3D s->scntl1; break; - case NCR710_SDID_REG: /* SDID */ + case NCR710_SDID: ret =3D s->sdid; break; - case NCR710_SIEN_REG: /* SIEN */ - ret =3D s->sien0; + case NCR710_SIEN: + ret =3D s->sien; break; - case NCR710_SCID_REG: + case NCR710_SCID: ret =3D s->scid; - if ((ret & 0x7F) =3D=3D 0) { - ret =3D 0x80 | NCR710_HOST_ID; - } else { - ret |=3D 0x80; - } break; - case NCR710_SXFER_REG: /* SXFER */ + case NCR710_SXFER: ret =3D s->sxfer; break; - case NCR710_SODL_REG: /* SODL */ + case NCR710_SODL: ret =3D s->sodl; break; - case NCR710_SOCL_REG: /* SOCL */ + case NCR710_SOCL: ret =3D s->socl; break; - case NCR710_SFBR_REG: /* SFBR */ + case NCR710_SFBR: ret =3D s->sfbr; break; - case NCR710_SIDL_REG: /* SIDL */ + case NCR710_SIDL: ret =3D s->sidl; break; - case NCR710_SBDL_REG: /* SBDL */ - ret =3D s->sbdl; - break; - case NCR710_SBCL_REG: /* SBCL */ - ret =3D 0; - if (s->scntl1 & NCR710_SCNTL1_CON) { - ret =3D s->sstat2 & PHASE_MASK; - ret |=3D s->sbcl; - if (s->socl & NCR710_SOCL_ATN) { - ret |=3D NCR710_SBCL_ATN; - } + case NCR710_SBDL: + /* Some drivers peek at the data bus during MSG IN. */ + if ((s->sstat2 & PHASE_MASK) =3D=3D PHASE_MI && s->msg_len > 0) { + ret =3D s->msg[0]; + } else { + ret =3D 0; } break; - case NCR710_DSTAT_REG: /* DSTAT */ - ret =3D s->dstat; - - /* - * Not freeing s->current here:: driver needs it for completion - * processing. It will be freed when the next command starts. - */ - if (s->dstat & NCR710_DSTAT_SIR) { - /* SIR bit set */ - } - s->dstat =3D 0; /* Clear all DMA interrupt status bits */ - s->dstat |=3D NCR710_DSTAT_DFE; - ncr710_update_irq(s); - - if (s->waiting =3D=3D NCR710_WAIT_RESELECT && s->current && - s->current->pending > 0) { - timer_mod(s->reselection_retry_timer, - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); - } - - if (!s->script_active && s->current && s->current->pending > 0 && - s->command_complete =3D=3D NCR710_CMD_COMPLETE) { - s->current->pending =3D 0; - s->waiting =3D NCR710_WAIT_NONE; - ncr710_execute_script(s); - } - - if (s->waiting && s->current && s->current->pending > 0 && - s->command_complete =3D=3D NCR710_CMD_COMPLETE) { - s->current->pending =3D 0; - s->waiting =3D NCR710_WAIT_NONE; - ncr710_execute_script(s); - } - - return ret; - case NCR710_SSTAT0_REG: /* SSTAT0 */ + case NCR710_SBCL: + ret =3D s->sbcl; + break; + case NCR710_DSTAT: + ret =3D s->dstat | LSI_DSTAT_DFE; + s->dstat =3D 0; + lsi_update_irq(s); + break; + case NCR710_SSTAT0: ret =3D s->sstat0; - if (s->sstat0 !=3D 0) { - s->sstat0 =3D 0; - s->istat &=3D ~NCR710_ISTAT_SIP; - ncr710_update_irq(s); - if (s->sbcl !=3D 0) { - s->sbcl =3D 0; - } - } + s->sstat0 =3D 0; + lsi_update_irq(s); break; - case NCR710_SSTAT1_REG: /* SSTAT1 */ - ret =3D s->sstat0; + case NCR710_SSTAT1: + ret =3D s->sstat1; break; - case NCR710_SSTAT2_REG: /* SSTAT2 */ + case NCR710_SSTAT2: ret =3D s->sstat2; break; - CASE_GET_REG32(dsa, NCR710_DSA_REG) + case NCR710_DSA ... NCR710_DSA + 3: + ret =3D extract32(s->dsa, 8 * (offset - NCR710_DSA), 8); break; - case NCR710_CTEST0_REG: /* CTEST0 */ + case NCR710_CTEST0: ret =3D s->ctest0; break; - case NCR710_CTEST1_REG: /* CTEST1 */ - ret =3D s->ctest1; + case NCR710_CTEST1: + ret =3D 0xf0; /* DMA FIFO empty */ break; - case NCR710_CTEST2_REG: /* CTEST2 */ - ret =3D s->ctest2; - s->ctest2 |=3D 0x04; - break; - case NCR710_CTEST3_REG: /* CTEST3 */ - ret =3D s->ctest3; - if (!ncr710_scsi_fifo_empty(&s->scsi_fifo)) { - uint8_t parity; - ret =3D ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity); - if (parity) { - s->ctest2 |=3D 0x10; - } else { - s->ctest2 &=3D ~0x10; - } + case NCR710_CTEST2: + ret =3D LSI_CTEST2_DACK; + if (s->istat & LSI_ISTAT0_SIGP) { + s->istat &=3D ~LSI_ISTAT0_SIGP; + ret |=3D LSI_CTEST2_SIGP; } break; - case NCR710_CTEST4_REG: /* CTEST4 */ + case NCR710_CTEST3: + ret =3D s->ctest3; + break; + case NCR710_CTEST4: ret =3D s->ctest4; break; - case NCR710_CTEST5_REG: /* CTEST5 */ + case NCR710_CTEST5: ret =3D s->ctest5; break; - case NCR710_CTEST6_REG: /* CTEST6 */ - ret =3D s->ctest6; + case NCR710_CTEST6: + ret =3D 0; break; - case NCR710_CTEST7_REG: /* CTEST7 */ + case NCR710_CTEST7: ret =3D s->ctest7; break; - CASE_GET_REG32(temp, NCR710_TEMP_REG) - case NCR710_DFIFO_REG: /* DFIFO */ + case NCR710_TEMP ... NCR710_TEMP + 3: + ret =3D extract32(s->temp, 8 * (offset - NCR710_TEMP), 8); + break; + case NCR710_DFIFO: ret =3D s->dfifo; - s->dfifo =3D 0; /* DMA FIFO count is always 0 */ break; - case NCR710_ISTAT_REG: /* ISTAT */ - ret =3D s->istat; + case NCR710_ISTAT: + ret =3D s->istat & ~LSI_ISTAT0_CON; + if (s->scntl1 & LSI_SCNTL1_CON) { + ret |=3D LSI_ISTAT0_CON; + } break; - case NCR710_CTEST8_REG: /* CTEST8 */ - ret =3D s->istat; + case NCR710_CTEST8: + ret =3D NCR710_CHIP_REVISION << 4; break; - case NCR710_LCRC_REG: /* LCRC */ + case NCR710_LCRC: ret =3D s->lcrc; break; - CASE_GET_REG24(dbc, NCR710_DBC_REG) - case NCR710_DCMD_REG: /* DCMD */ + case NCR710_DBC ... NCR710_DBC + 2: + ret =3D extract32(s->dbc, 8 * (offset - NCR710_DBC), 8); + break; + case NCR710_DCMD: ret =3D s->dcmd; break; - CASE_GET_REG32(dnad, NCR710_DNAD_REG) - case NCR710_DSP_REG: - ret =3D s->dsp & 0xff; + case NCR710_DNAD ... NCR710_DNAD + 3: + ret =3D extract32(s->dnad, 8 * (offset - NCR710_DNAD), 8); break; - case NCR710_DSP_REG + 1: - ret =3D (s->dsp >> 8) & 0xff; + case NCR710_DSP ... NCR710_DSP + 3: + ret =3D extract32(s->dsp, 8 * (offset - NCR710_DSP), 8); break; - case NCR710_DSP_REG + 2: - ret =3D (s->dsp >> 16) & 0xff; + case NCR710_DSPS ... NCR710_DSPS + 3: + ret =3D extract32(s->dsps, 8 * (offset - NCR710_DSPS), 8); break; - case NCR710_DSP_REG + 3: - ret =3D (s->dsp >> 24) & 0xff; - if (s->dsps =3D=3D GOOD_STATUS_AFTER_STATUS && - (s->dstat & NCR710_DSTAT_SIR)) { - s->dstat &=3D ~NCR710_DSTAT_SIR; - ncr710_update_irq(s); - } + case NCR710_SCRATCH ... NCR710_SCRATCH + 3: + ret =3D extract32(s->scratch, 8 * (offset - NCR710_SCRATCH), 8); break; - case NCR710_DSPS_REG: - ret =3D s->dsps & 0xff; - break; - case NCR710_DSPS_REG + 1: - ret =3D (s->dsps >> 8) & 0xff; - break; - case NCR710_DSPS_REG + 2: - ret =3D (s->dsps >> 16) & 0xff; - break; - case NCR710_DSPS_REG + 3: - ret =3D (s->dsps >> 24) & 0xff; - if (!(s->dstat & NCR710_DSTAT_SIR) && s->dsps !=3D 0) { - s->dsps =3D 0; - } - break; - CASE_GET_REG32(scratch, NCR710_SCRATCH_REG) - break; - case NCR710_DMODE_REG: /* DMODE */ + case NCR710_DMODE: ret =3D s->dmode; break; - case NCR710_DIEN_REG: /* DIEN */ + case NCR710_DIEN: ret =3D s->dien; break; - case NCR710_DWT_REG: /* DWT */ + case NCR710_DWT: ret =3D s->dwt; break; - case NCR710_DCNTL_REG: /* DCNTL */ + case NCR710_DCNTL: ret =3D s->dcntl; - return ret; - CASE_GET_REG32(adder, NCR710_ADDER_REG) + break; + case NCR710_ADDER ... NCR710_ADDER + 3: + ret =3D extract32(s->adder, 8 * (offset - NCR710_ADDER), 8); break; default: - ret =3D 0; + qemu_log_mask(LOG_GUEST_ERROR, + "ncr710: invalid read from reg %s 0x%x\n", + lsi_reg_name(offset), offset); + ret =3D 0xff; break; } =20 -#undef CASE_GET_REG24 -#undef CASE_GET_REG32 + trace_ncr710_reg_read(lsi_reg_name(offset), offset, ret); return ret; } =20 -static void ncr710_reg_writeb(NCR710State *s, int offset, uint8_t val) +static void lsi_reg_writeb(NCR710State *s, int offset, uint8_t val) { - uint8_t old_val; - -#define CASE_SET_REG24(name, addr) \ - case addr: \ - s->name &=3D 0xffffff00; \ - s->name |=3D val; \ - break; \ - case addr + 1: \ - s->name &=3D 0xffff00ff; \ - s->name |=3D val << 8; \ - break; \ - case addr + 2: \ - s->name &=3D 0xff00ffff; \ - s->name |=3D val << 16; \ - break; - -#define CASE_SET_REG32(name, addr) \ - case addr: \ - s->name &=3D 0xffffff00; \ - s->name |=3D val; \ - break; \ - case addr + 1: \ - s->name &=3D 0xffff00ff; \ - s->name |=3D val << 8; \ - break; \ - case addr + 2: \ - s->name &=3D 0xff00ffff; \ - s->name |=3D val << 16; \ - break; \ - case addr + 3: \ - s->name &=3D 0x00ffffff; \ - s->name |=3D val << 24; \ - break; - - trace_ncr710_reg_write(ncr710_reg_name(offset), offset, val); + trace_ncr710_reg_write(lsi_reg_name(offset), offset, val); =20 switch (offset) { - case NCR710_SCNTL0_REG: /* SCNTL0 */ - old_val =3D s->scntl0; + case NCR710_SCNTL0: s->scntl0 =3D val; - break; - - case NCR710_SCNTL1_REG: /* SCNTL1 */ - old_val =3D s->scntl1; - s->scntl1 =3D val; - - - /* Handle Assert Even SCSI Parity (AESP) bit changes */ - if ((val & NCR710_SCNTL1_AESP) !=3D (old_val & NCR710_SCNTL1_AESP)= ) { - trace_ncr710_parity_sense_changed((val & NCR710_SCNTL1_AESP) - !=3D 0 ? "even" : "odd"); + if (val & LSI_SCNTL0_START) { + qemu_log_mask(LOG_UNIMP, "ncr710: START not implemented\n"); } - - if (val & NCR710_SCNTL1_RST) { - if (!(s->sstat0 & NCR710_SSTAT0_RST)) { - s->sstat0 |=3D NCR710_SSTAT0_RST; - ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_RST); - } - if (!(old_val & NCR710_SCNTL1_RST)) { - NCR710_DPRINTF("NCR710: SCNTL1: SCSI bus reset " - "initiated\n"); - ncr710_soft_reset(s); + break; + case NCR710_SCNTL1: + s->scntl1 =3D val; + if (val & LSI_SCNTL1_RST) { + if (!(s->sstat0 & LSI_STAT0_RST)) { + bus_cold_reset(BUS(&s->bus)); + s->sstat0 |=3D LSI_STAT0_RST; + lsi_script_scsi_interrupt(s, LSI_STAT0_RST); } } else { - s->sstat0 &=3D ~NCR710_SSTAT0_RST; + s->sstat0 &=3D ~LSI_STAT0_RST; } break; - - case NCR710_SDID_REG: /* SDID */ - s->sdid =3D val & 0x0F; /* Only lower 4 bits are valid */ + case NCR710_SDID: + s->sdid =3D val; break; - - case NCR710_SIEN_REG: /* SIEN */ - s->sien0 =3D val; - NCR710_DPRINTF("SIEN: interrupt mask=3D0x%02x\n", val); - ncr710_update_irq(s); + case NCR710_SIEN: + s->sien =3D val; + lsi_update_irq(s); break; - - case NCR710_SCID_REG: /* SCID */ + case NCR710_SCID: s->scid =3D val; break; - - case NCR710_SXFER_REG: /* SXFER */ + case NCR710_SXFER: s->sxfer =3D val; break; - - case NCR710_SODL_REG: /* SODL */ + case NCR710_SODL: s->sodl =3D val; - s->sstat1 |=3D NCR710_SSTAT1_ORF; /* SCSI Output Register Full */ break; - - case NCR710_SOCL_REG: /* SOCL */ + case NCR710_SOCL: s->socl =3D val; break; - - case NCR710_SFBR_REG: /* SFBR */ + case NCR710_SFBR: + /* CPU may not write SFBR, but SCRIPTS register moves do. */ s->sfbr =3D val; break; - - case NCR710_SIDL_REG: /* SIDL */ - case NCR710_SBDL_REG: /* SBDL */ + case NCR710_SIDL: + case NCR710_SBDL: + /* Read only. */ break; - - case NCR710_SBCL_REG: /* SBCL */ + case NCR710_SBCL: s->sbcl =3D val; - ncr710_set_phase(s, val & PHASE_MASK); break; - - case NCR710_DSTAT_REG: - case NCR710_SSTAT0_REG: - case NCR710_SSTAT1_REG: - case NCR710_SSTAT2_REG: - /* Linux writes to these readonly registers on startup */ - return; - - case NCR710_DSA_REG: - s->dsa &=3D 0xffffff00; - s->dsa |=3D val; + case NCR710_DSTAT: + case NCR710_SSTAT0: + case NCR710_SSTAT1: + case NCR710_SSTAT2: + /* Read only status registers. */ break; - case NCR710_DSA_REG + 1: - s->dsa &=3D 0xffff00ff; - s->dsa |=3D val << 8; + case NCR710_DSA ... NCR710_DSA + 3: + s->dsa =3D deposit32(s->dsa, 8 * (offset - NCR710_DSA), 8, val); break; - case NCR710_DSA_REG + 2: - s->dsa &=3D 0xff00ffff; - s->dsa |=3D val << 16; - break; - case NCR710_DSA_REG + 3: - s->dsa &=3D 0x00ffffff; - s->dsa |=3D val << 24; - break; - - case NCR710_CTEST0_REG: /* CTEST0 */ + case NCR710_CTEST0: s->ctest0 =3D val; break; - - case NCR710_CTEST1_REG: /* CTEST1, read-only */ - s->ctest1 =3D val; + case NCR710_CTEST1: + case NCR710_CTEST2: + /* Read only. */ break; - - case NCR710_CTEST2_REG: /* CTEST2, read-only */ - s->ctest2 =3D val; - break; - - case NCR710_CTEST3_REG: /* CTEST3 */ + case NCR710_CTEST3: s->ctest3 =3D val; break; - - case NCR710_CTEST4_REG: /* CTEST4 */ + case NCR710_CTEST4: s->ctest4 =3D val; break; - - case NCR710_CTEST5_REG: /* CTEST5 */ + case NCR710_CTEST5: s->ctest5 =3D val; break; - - case NCR710_CTEST6_REG: /* CTEST6 */ - s->ctest6 =3D val; + case NCR710_CTEST6: break; - - case NCR710_CTEST7_REG: /* CTEST7 */ + case NCR710_CTEST7: s->ctest7 =3D val; break; - - CASE_SET_REG32(temp, NCR710_TEMP_REG) - - case NCR710_DFIFO_REG: /* DFIFO, read-only */ + case NCR710_TEMP ... NCR710_TEMP + 3: + s->temp =3D deposit32(s->temp, 8 * (offset - NCR710_TEMP), 8, val); break; - - case NCR710_ISTAT_REG: /* ISTAT */ - old_val =3D s->istat; - - if ((old_val & NCR710_ISTAT_DIP) && !(val & NCR710_ISTAT_DIP)) { - /* Clear script interrupt data after Linux processes it */ - s->dstat =3D 0; - s->dsps =3D 0; + case NCR710_DFIFO: + s->dfifo =3D val; + break; + case NCR710_ISTAT: + s->istat =3D (s->istat & ~(LSI_ISTAT0_ABRT | LSI_ISTAT0_SRST | + LSI_ISTAT0_SIGP)) | + (val & (LSI_ISTAT0_ABRT | LSI_ISTAT0_SRST | + LSI_ISTAT0_SIGP)); + if (val & LSI_ISTAT0_SRST) { + ncr710_soft_reset(s); + return; } - - if ((old_val & NCR710_ISTAT_SIP) && !(val & NCR710_ISTAT_SIP)) { - s->sstat0 =3D 0; + if (val & LSI_ISTAT0_ABRT) { + lsi_script_dma_interrupt(s, LSI_DSTAT_ABRT); } - - s->istat =3D (val & ~(NCR710_ISTAT_DIP | NCR710_ISTAT_SIP)) | - (s->istat & (NCR710_ISTAT_DIP | NCR710_ISTAT_SIP)); - ncr710_update_irq(s); - - if (val & NCR710_ISTAT_ABRT) { - ncr710_script_dma_interrupt(s, NCR710_DSTAT_ABRT); + if (s->waiting =3D=3D LSI_WAIT_RESELECT && (val & LSI_ISTAT0_SIGP)= ) { + /* + * SIGP wake of a parked Wait Reselect. Run the engine + * synchronously: this SELECT must take priority over any + * disconnected command pending reselection. The guest takes = any + * IRQ raised here after this store returns. + */ + trace_ncr710_awoken(); + s->waiting =3D LSI_NOWAIT; + s->dsp =3D s->dnad; + lsi_execute_script(s); } break; - - case NCR710_CTEST8_REG: /* CTEST8 */ - if (val & 0x08) { - s->dstat |=3D NCR710_DSTAT_DFE; - } - if (val & 0x04) { - ncr710_scsi_fifo_init(&s->scsi_fifo); - s->dstat |=3D NCR710_DSTAT_DFE; - s->ctest1 =3D 0xFF; - } else if (s->ctest8 & 0x04) { - s->ctest1 =3D 0x00; - } - s->ctest8 =3D val; + case NCR710_CTEST8: + /* + * Revision is read only; FLF/CLF FIFO ops do nothing (the FIFO is + * modelled as always empty). + */ break; - case NCR710_LCRC_REG: /* LCRC */ - s->lcrc =3D val; + case NCR710_LCRC: + /* Writing clears the longitudinal parity accumulator. */ + s->lcrc =3D 0; break; - - CASE_SET_REG24(dbc, NCR710_DBC_REG) - - case NCR710_DCMD_REG: /* DCMD */ + case NCR710_DBC ... NCR710_DBC + 2: + s->dbc =3D deposit32(s->dbc, 8 * (offset - NCR710_DBC), 8, val); + break; + case NCR710_DCMD: s->dcmd =3D val; break; - - CASE_SET_REG32(dnad, NCR710_DNAD_REG) - case 0x2c: /* DSP[0:7] */ - s->dsp &=3D 0xffffff00; - s->dsp |=3D val; + case NCR710_DNAD ... NCR710_DNAD + 3: + s->dnad =3D deposit32(s->dnad, 8 * (offset - NCR710_DNAD), 8, val); break; - case 0x2d: /* DSP[8:15] */ - s->dsp &=3D 0xffff00ff; - s->dsp |=3D val << 8; + case NCR710_DSP: + s->dsp =3D (s->dsp & 0xffffff00) | val; break; - case 0x2e: /* DSP[16:23] */ - s->dsp &=3D 0xff00ffff; - s->dsp |=3D val << 16; + case NCR710_DSP + 1: + s->dsp =3D (s->dsp & 0xffff00ff) | (val << 8); break; - case 0x2f: /* DSP[24:31] */ - s->dsp &=3D 0x00ffffff; - s->dsp |=3D val << 24; - s->waiting =3D NCR710_WAIT_NONE; - s->script_active =3D 1; - s->istat |=3D NCR710_ISTAT_CON; - ncr710_clear_selection_timeout(s); - ncr710_execute_script(s); + case NCR710_DSP + 2: + s->dsp =3D (s->dsp & 0xff00ffff) | (val << 16); break; - CASE_SET_REG32(dsps, NCR710_DSPS_REG) - CASE_SET_REG32(scratch, NCR710_SCRATCH_REG) - break; - - case NCR710_DMODE_REG: /* DMODE */ - s->dmode =3D val; - break; - - case NCR710_DIEN_REG: /* DIEN */ - s->dien =3D val; - NCR710_DPRINTF("DIEN: interrupt enable=3D0x%02x\n", val); - ncr710_update_irq(s); - break; - - case NCR710_DWT_REG: /* DWT */ - s->dwt =3D val; - break; - - case NCR710_DCNTL_REG: /* DCNTL */ - s->dcntl =3D val & ~(NCR710_DCNTL_PFF); - if (val & NCR710_DCNTL_STD) { - s->waiting =3D NCR710_WAIT_NONE; - ncr710_execute_script(s); - s->dcntl &=3D ~NCR710_DCNTL_STD; + case NCR710_DSP + 3: + s->dsp =3D (s->dsp & 0x00ffffff) | (val << 24); + /* Writing the high byte starts SCRIPTS unless in manual start mod= e. */ + if (!(s->dmode & LSI_DMODE_MAN) && !s->script_running) { + lsi_execute_script(s); } break; - - CASE_SET_REG32(adder, NCR710_ADDER_REG) + case NCR710_DSPS ... NCR710_DSPS + 3: + s->dsps =3D deposit32(s->dsps, 8 * (offset - NCR710_DSPS), 8, val); + break; + case NCR710_SCRATCH ... NCR710_SCRATCH + 3: + s->scratch =3D deposit32(s->scratch, 8 * (offset - NCR710_SCRATCH), + 8, val); + break; + case NCR710_DMODE: + s->dmode =3D val; + break; + case NCR710_DIEN: + s->dien =3D val; + lsi_update_irq(s); + break; + case NCR710_DWT: + s->dwt =3D val; + break; + case NCR710_DCNTL: + s->dcntl =3D val & ~LSI_DCNTL_STD; + if ((val & LSI_DCNTL_STD) && !s->script_running) { + lsi_execute_script(s); + } break; - default: + qemu_log_mask(LOG_GUEST_ERROR, + "ncr710: invalid write to reg %s 0x%x (0x%02x)\n", + lsi_reg_name(offset), offset, val); break; } - -#undef CASE_SET_REG24 -#undef CASE_SET_REG32 } =20 -/* Memory region wrapper for NCR710 registers */ -uint64_t ncr710_reg_read(void *opaque, hwaddr addr, unsigned size) + +uint64_t ncr710_reg_read(NCR710State *s, hwaddr addr, unsigned size) +{ + /* The LASI wrapper decomposes multibyte accesses into single bytes. */ + return lsi_reg_readb(s, addr & 0xff); +} + +void ncr710_reg_write(NCR710State *s, hwaddr addr, uint64_t val, unsigned = size) +{ + lsi_reg_writeb(s, addr & 0xff, val & 0xff); +} + +static int lsi_pre_save(void *opaque) { NCR710State *s =3D opaque; - uint8_t offset =3D addr & 0xff; - uint8_t val =3D ncr710_reg_readb(s, offset); - trace_ncr710_reg_read(ncr710_reg_name(offset), offset, val); - return val; -} =20 -void ncr710_reg_write(void *opaque, hwaddr addr, uint64_t val, unsigned si= ze) -{ - NCR710State *s =3D opaque; - uint8_t offset =3D addr & 0xff; - uint8_t val8 =3D val & 0xff; - trace_ncr710_reg_write(ncr710_reg_name(offset), offset, val8); - ncr710_reg_writeb(s, offset, val8); -} - -/* Device reset */ -static void ncr710_device_reset(DeviceState *dev) -{ - SysBusNCR710State *sysbus_dev =3D SYSBUS_NCR710_SCSI(dev); - NCR710State *s =3D &sysbus_dev->ncr710; - - ncr710_soft_reset(s); - /* A device reset clears EA and FC1; only ISTAT.RST keeps them. */ - s->dcntl =3D 0; - s->dmode =3D 0; -} - -static const struct SCSIBusInfo ncr710_scsi_info =3D { - .tcq =3D true, - .max_target =3D 8, - .max_lun =3D 8, /* Full LUN support */ - - .transfer_data =3D ncr710_transfer_data, - .complete =3D ncr710_command_complete, - .cancel =3D ncr710_request_cancelled, -}; - -static const MemoryRegionOps ncr710_mmio_ops =3D { - .read =3D ncr710_reg_read, - .write =3D ncr710_reg_write, - .endianness =3D DEVICE_LITTLE_ENDIAN, - .valid =3D { - .min_access_size =3D 1, - .max_access_size =3D 4, - }, -}; - -static const VMStateDescription vmstate_ncr710_scsi_fifo =3D { - .name =3D "ncr710_scsi_fifo", - .version_id =3D 1, - .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { - VMSTATE_UINT8_ARRAY(data, NCR710_SCSI_FIFO, NCR710_SCSI_FIFO_SIZE), - VMSTATE_UINT8_ARRAY(parity, NCR710_SCSI_FIFO, NCR710_SCSI_FIFO_SIZ= E), - VMSTATE_INT32(count, NCR710_SCSI_FIFO), - VMSTATE_END_OF_LIST() + if (s->current) { + assert(s->current->dma_buf =3D=3D NULL); + assert(s->current->dma_len =3D=3D 0); } -}; + return 0; +} + +static int lsi_post_load(void *opaque, int version_id) +{ + NCR710State *s =3D opaque; + + if (s->msg_len < 0 || s->msg_len > LSI_MAX_MSGIN_LEN) { + return -EINVAL; + } + if (s->msg_action < LSI_MSG_ACTION_COMMAND || + s->msg_action > LSI_MSG_ACTION_DIN) { + return -EINVAL; + } + if (s->waiting < LSI_NOWAIT || s->waiting > LSI_WAIT_SCRIPTS) { + return -EINVAL; + } + if (s->current_lun < 0 || s->current_lun > 7) { + return -EINVAL; + } + if (s->waiting =3D=3D LSI_WAIT_SCRIPTS) { + lsi_scripts_timer_start(s); + } + return 0; +} =20 const VMStateDescription vmstate_ncr710 =3D { .name =3D "ncr710", .version_id =3D 1, .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { + .pre_save =3D lsi_pre_save, + .post_load =3D lsi_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_INT32(carry, NCR710State), + VMSTATE_INT32(status, NCR710State), + VMSTATE_INT32(msg_action, NCR710State), + VMSTATE_INT32(msg_len, NCR710State), + VMSTATE_BUFFER(msg, NCR710State), + VMSTATE_INT32(waiting, NCR710State), + VMSTATE_INT32(current_lun, NCR710State), + VMSTATE_UINT32(select_tag, NCR710State), + VMSTATE_INT32(command_complete, NCR710State), + VMSTATE_BOOL(script_running, NCR710State), + VMSTATE_UINT8(scntl0, NCR710State), VMSTATE_UINT8(scntl1, NCR710State), VMSTATE_UINT8(sdid, NCR710State), - VMSTATE_UINT8(sien0, NCR710State), + VMSTATE_UINT8(sien, NCR710State), VMSTATE_UINT8(scid, NCR710State), VMSTATE_UINT8(sxfer, NCR710State), VMSTATE_UINT8(sodl, NCR710State), @@ -2324,156 +1552,27 @@ const VMStateDescription vmstate_ncr710 =3D { VMSTATE_UINT8(sstat0, NCR710State), VMSTATE_UINT8(sstat1, NCR710State), VMSTATE_UINT8(sstat2, NCR710State), + VMSTATE_UINT32(dsa, NCR710State), VMSTATE_UINT8(ctest0, NCR710State), - VMSTATE_UINT8(ctest1, NCR710State), - VMSTATE_UINT8(ctest2, NCR710State), VMSTATE_UINT8(ctest3, NCR710State), VMSTATE_UINT8(ctest4, NCR710State), VMSTATE_UINT8(ctest5, NCR710State), - VMSTATE_UINT8(ctest6, NCR710State), VMSTATE_UINT8(ctest7, NCR710State), - VMSTATE_UINT8(ctest8, NCR710State), VMSTATE_UINT32(temp, NCR710State), VMSTATE_UINT8(dfifo, NCR710State), VMSTATE_UINT8(istat, NCR710State), VMSTATE_UINT8(lcrc, NCR710State), - VMSTATE_UINT8(dcmd, NCR710State), - VMSTATE_UINT8(dmode, NCR710State), - VMSTATE_UINT8(dien, NCR710State), - VMSTATE_UINT8(dwt, NCR710State), - VMSTATE_UINT8(dcntl, NCR710State), - VMSTATE_UINT32(dsa, NCR710State), VMSTATE_UINT32(dbc, NCR710State), + VMSTATE_UINT8(dcmd, NCR710State), VMSTATE_UINT32(dnad, NCR710State), VMSTATE_UINT32(dsp, NCR710State), VMSTATE_UINT32(dsps, NCR710State), VMSTATE_UINT32(scratch, NCR710State), + VMSTATE_UINT8(dmode, NCR710State), + VMSTATE_UINT8(dien, NCR710State), + VMSTATE_UINT8(dwt, NCR710State), + VMSTATE_UINT8(dcntl, NCR710State), VMSTATE_UINT32(adder, NCR710State), - VMSTATE_STRUCT(scsi_fifo, NCR710State, 1, - vmstate_ncr710_scsi_fifo, NCR710_SCSI_FIFO), - VMSTATE_UINT8(status, NCR710State), - VMSTATE_UINT8_ARRAY(msg, NCR710State, - NCR710_MAX_MSGIN_LEN), - VMSTATE_UINT8(msg_len, NCR710State), - VMSTATE_UINT8(msg_action, NCR710State), - VMSTATE_INT32(carry, NCR710State), - VMSTATE_BOOL(script_active, NCR710State), - VMSTATE_INT32(waiting, NCR710State), - VMSTATE_UINT8(command_complete, NCR710State), - VMSTATE_UINT32(select_tag, NCR710State), - VMSTATE_UINT8(current_lun, NCR710State), VMSTATE_END_OF_LIST() } }; - -static const VMStateDescription vmstate_sysbus_ncr710 =3D { - .name =3D "sysbus_ncr710", - .version_id =3D 1, - .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { - VMSTATE_STRUCT(ncr710, SysBusNCR710State, 1, vmstate_ncr710, - NCR710State), - VMSTATE_END_OF_LIST() - } -}; - -DeviceState *ncr710_device_create_sysbus(hwaddr addr, qemu_irq irq) -{ - DeviceState *dev; - SysBusDevice *sysbus; - - dev =3D qdev_new(TYPE_SYSBUS_NCR710_SCSI); - sysbus =3D SYS_BUS_DEVICE(dev); - - qdev_realize_and_unref(dev, NULL, &error_abort); - sysbus_mmio_map(sysbus, 0, addr); - sysbus_connect_irq(sysbus, 0, irq); - return dev; -} - -DeviceState *ncr53c710_init(MemoryRegion *address_space, hwaddr addr, - qemu_irq irq) -{ - DeviceState *dev; - SysBusDevice *sysbus; - SysBusNCR710State *s; - - /* trace_ncr710_device_init(addr); */ - - dev =3D qdev_new(TYPE_SYSBUS_NCR710_SCSI); - sysbus =3D SYS_BUS_DEVICE(dev); - - qdev_realize_and_unref(dev, NULL, &error_abort); - sysbus_mmio_map(sysbus, 0, addr); - sysbus_connect_irq(sysbus, 0, irq); - - s =3D SYSBUS_NCR710_SCSI(dev); - if (!s->ncr710.as) { - s->ncr710.as =3D &address_space_memory; - } - - return dev; -} - -static void sysbus_ncr710_realize(DeviceState *dev, Error **errp) -{ - SysBusNCR710State *s =3D SYSBUS_NCR710_SCSI(dev); - - trace_ncr710_device_realize(); - scsi_bus_init(&s->ncr710.bus, sizeof(s->ncr710.bus), dev, - &ncr710_scsi_info); - s->ncr710.as =3D &address_space_memory; - - ncr710_scsi_fifo_init(&s->ncr710.scsi_fifo); - s->ncr710.dcntl &=3D ~NCR710_DCNTL_COM; - s->ncr710.scid =3D 0x80 | NCR710_HOST_ID; - - s->ncr710.reselection_retry_timer =3D - timer_new_ns(QEMU_CLOCK_VIRTUAL, - ncr710_reselection_retry_callback, - &s->ncr710); - - memset(s->ncr710.msg, 0, sizeof(s->ncr710.msg)); - - memory_region_init_io(&s->iomem, OBJECT(s), &ncr710_mmio_ops, &s->ncr7= 10, - "ncr710", 0x100); - sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); - sysbus_init_irq(SYS_BUS_DEVICE(s), &s->ncr710.irq); - -} - -static void sysbus_ncr710_init(Object *obj) -{ - SysBusNCR710State *s =3D SYSBUS_NCR710_SCSI(obj); - memset(&s->ncr710, 0, sizeof(NCR710State)); - s->ncr710.ctest0 =3D 0x01; - s->ncr710.scid =3D 0x80 | NCR710_HOST_ID; - s->ncr710.dstat =3D NCR710_DSTAT_DFE; -} - -static void sysbus_ncr710_class_init(ObjectClass *oc, const void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(oc); - - dc->realize =3D sysbus_ncr710_realize; - device_class_set_legacy_reset(dc, ncr710_device_reset); - dc->bus_type =3D NULL; - set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); - dc->desc =3D "NCR53C710 SCSI I/O Processor (SysBus)"; - dc->vmsd =3D &vmstate_sysbus_ncr710; -} - -static const TypeInfo sysbus_ncr710_info =3D { - .name =3D TYPE_SYSBUS_NCR710_SCSI, - .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(SysBusNCR710State), - .instance_init =3D sysbus_ncr710_init, - .class_init =3D sysbus_ncr710_class_init, -}; - -static void ncr710_register_types(void) -{ - type_register_static(&sysbus_ncr710_info); -} - -type_init(ncr710_register_types) diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index a8ac1e7f1d44..f0eb1457022e 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -314,9 +314,32 @@ ncr710_script_scsi_interrupt(uint8_t stat0, uint8_t ss= tat0) "SCSI interrupt stat ncr710_script_dma_interrupt(uint8_t stat, uint8_t dstat) "DMA interrupt st= at=3D0x%02x dstat=3D0x%02x" ncr710_command_complete(uint32_t tag, uint8_t status) "tag=3D0x%x status= =3D0x%02x" ncr710_disconnect(uint8_t waiting) "waiting=3D%d" +ncr710_reselect(int id) "Reselect id=3D%d" +ncr710_queue_command(uint32_t tag) "queue command tag=3D0x%x" +ncr710_queue_req(uint32_t tag) "defer queued req tag=3D0x%x" ncr710_bad_selection(uint32_t target) "target=3D%d" -ncr710_parity_sense_changed(const char *parity) "Parity sense changed to %= s" -ncr710_device_realize(void) "Device realized" +ncr710_execute_script(uint32_t dsp, uint32_t insn, uint32_t addr) "dsp=3D0= x%08x insn=3D0x%08x addr=3D0x%08x" +ncr710_do_dma(uint32_t addr, uint32_t len) "addr=3D0x%08x len=3D%d" +ncr710_do_command(uint32_t dbc, uint8_t op, uint32_t lba, uint32_t xfer) "= len=3D%d op=3D0x%02x lba=3D%u xfer=3D%u" +ncr710_do_status(uint32_t dbc, uint8_t status) "len=3D%d status=3D0x%02x" +ncr710_do_msgin(uint32_t dbc, int msg_len) "len=3D%d msg_len=3D%d" +ncr710_do_msgout(uint32_t dbc) "len=3D%d" +ncr710_transfer_data(uint32_t tag, uint32_t len) "tag=3D0x%x len=3D%d" +ncr710_awoken(void) "SIGP woke Wait Reselect" +ncr710_set_phase(int phase) "phase=3D%d" +ncr710_update_irq(int level, uint8_t istat, uint8_t sstat0, uint8_t dstat)= "level=3D%d istat=3D0x%02x sstat0=3D0x%02x dstat=3D0x%02x" +ncr710_select(int id, int atn) "Select id=3D%d atn=3D%d" +ncr710_block_move_badphase(int have, int want) "phase mismatch have=3D%d w= ant=3D%d" +ncr710_resume_script(int waiting) "resume waiting=3D%d" +ncr710_script_yield(int insns) "yield after %d insns" +ncr710_tc_jump(uint32_t addr) "JUMP 0x%08x" +ncr710_tc_call(uint32_t addr) "CALL 0x%08x" +ncr710_tc_return(uint32_t addr) "RETURN 0x%08x" +ncr710_interrupt_insn(uint32_t dsps) "INT vector=3D0x%08x" +ncr710_memmove(uint32_t dest, uint32_t src, int count) "MOVE MEMORY dest= =3D0x%08x src=3D0x%08x count=3D%d" +ncr710_do_dma_unavailable(void) "DMA: data not yet available" +ncr710_wait_disconnect(void) "Wait Disconnect" +ncr710_illegal_insn(uint32_t insn) "ILLEGAL instruction 0x%08x" =20 # lasi_ncr710.c lasi_ncr710_device_realize(void) "Device realized" @@ -324,16 +347,13 @@ lasi_ncr710_device_reset(void) "Device reset" lasi_ncr710_reg_read(uint32_t addr, uint32_t val, unsigned size) "addr=3D0= x%03x val=3D0x%08x size=3D%u" lasi_ncr710_reg_write(uint32_t addr, uint32_t val, unsigned size) "addr=3D= 0x%03x val=3D0x%08x size=3D%u" lasi_ncr710_reg_read_id(uint32_t hw_type, uint32_t sversion, uint32_t val)= "hw_type=3D%u sversion=3D0x%04x val=3D0x%08x" -lasi_ncr710_reg_read_hversion(uint32_t hversion) "LASI NCR710: HVersion re= ad -> 0x%02x" -lasi_ncr710_reg_forward_read(uint32_t addr, uint32_t val) "LASI NCR710: Fo= rward read to NCR710 core addr=3D0x%03x val=3D0x%08x" -lasi_ncr710_reg_forward_write(uint32_t addr, uint32_t val) "LASI NCR710: F= orward write to NCR710 core addr=3D0x%03x val=3D0x%08x" -lasi_ncr710_command_complete(uint32_t status, size_t resid) "LASI NCR710: = Command complete status=3D0x%02x resid=3D%zu" -lasi_ncr710_transfer_data(uint32_t len) "LASI NCR710: Transfer data len=3D= %u" -lasi_ncr710_request_cancelled(void *req) "LASI NCR710: Request cancelled r= eq=3D%p" +lasi_ncr710_reg_read_hversion(uint32_t hversion) "HVersion read -> 0x%02x" +lasi_ncr710_reg_forward_read(uint32_t addr, uint32_t val) "Forward read to= NCR710 core addr=3D0x%03x val=3D0x%08x" +lasi_ncr710_reg_forward_write(uint32_t addr, uint32_t val) "Forward write = to NCR710 core addr=3D0x%03x val=3D0x%08x" +lasi_ncr710_command_complete(uint32_t status, size_t resid) "Command compl= ete status=3D0x%02x resid=3D%zu" +lasi_ncr710_transfer_data(uint32_t len) "Transfer data len=3D%u" +lasi_ncr710_request_cancelled(void *req) "Request cancelled req=3D%p" lasi_ncr710_timers_initialized(uint64_t reselection) "Timers: reselection= =3D0x%" PRIx64 -lasi_ncr710_handle_legacy_cmdline(int busnr, int found_drives) "LASI NCR71= 0: Handle legacy cmdline busnr=3D%d found_drives=3D%d" -lasi_ncr710_legacy_drive_found(int busnr, int unit) "LASI NCR710: Found le= gacy drive at bus=3D%d unit=3D%d" -lasi_ncr710_scsi_device_created(const char *type) "LASI NCR710: SCSI devic= e created: %s" =20 # virtio-scsi.c virtio_scsi_cmd_req(int lun, uint32_t tag, uint8_t cmd) "virtio_scsi_cmd_r= eq lun=3D%u tag=3D0x%x cmd=3D0x%x" --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194918; cv=none; d=zohomail.com; s=zohoarc; b=aRFJcWjasrfPAY5A5rOu/NP/Kj2WFXcXIdpm9IfRHzTEsGcvkXYtY6+24DOncqfEZth75UeHFwAnZ40q16DnCkXhOB9BwEMWRZbZ7+6doCkTIQ7VBxuXg5GGj780Ssd0GuGJC5HRMohOv9NLxOueiHyfmXOLG0E0KSj2KGD1wvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194918; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GNutknphZQYW/QLgcDhW3Ed6+xGQZtXRUfm12mKXV6c=; b=WRgKAreaoX6iIqfJnQyZSjaYRk/UiRxVl/ERZVZTCcGhmCpXaVzIot08pbCV9/sY2H4xixDhymoehpiOkAVVciyvFcjIjL/rzW5NimVmZhB6RYRCljPMk0o/bVfs72olIDSelDPsdtmUNdpzVTiVIoOjYt3aAduS1HrGzc1sayk= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194918495777.8406694950196; Fri, 20 Nov 2026 09:15:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBX-0003Zi-SM; Fri, 20 Nov 2026 12:14:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBA-0003Ga-Sl for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:43 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSB8-0003tO-Se for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:40 -0500 Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfiiG2947046 for ; Fri, 20 Nov 2026 17:13:37 GMT Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjjaw8r-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:37 +0000 (GMT) Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-921273a6cacso17853816d6.0 for ; Fri, 20 Nov 2026 09:13:37 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab5ffcad11sm6777993f8f.0.2026.11.20.09.13.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= GNutknphZQYW/QLgcDhW3Ed6+xGQZtXRUfm12mKXV6c=; b=E1NtRkQciC+I0DnW AAW7ZQ22ZfsKAyYbfUjvK5FfhjMnq+9cr1DCvKjSubMcgzcdRvh9H7TVYmo2j41V 51wqoMd9WVHtbJH6ZnenYGcy4tDFCiuCjOwmt9OeuADK2NpKMgFEULeKFPAMmYu0 pI4wjZXyaQciyYI8ZPqhKPybc98FAUekduQuBjeK/LbsmnSzUPWL+vibKd5kD97O 3LnmxIz5uUNT6caurHttuBHTQ/fKP8fEmVdvqdopMroS/ZA7ADR+sqT+cx/Rf7YA RtHuXK+QCbtqwxezS3ymlp5SNaMqyD6q/cy8HGvsxJLrvKZJr6MvzYLvkxN8fhvD vdWoUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194816; x=1795799616; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=GNutknphZQYW/QLgcDhW3Ed6+xGQZtXRUfm12mKXV6c=; b=kOYlbI+dmp7YPupcR9QcPL+JMieBxPB1WB38Zplv5r/w1AMNnITU3Tnxj9s+5/cA22 w84pIazuM2WgJOXPSPAtoi5p7S3FuBk6aoz0XbCE18E+VegL2jQBrUn9SLb2h69oueIn lxi0hfMDC9J6rpUsmOxB4J9/wu/5RrXxQ/eXQ6nlSIALsn/+7i2QRv5nXgKbnLFaOAU0 /snlwOl021kj1GFxLuwuMz3Z1fiT1GmuWXhXHnU5k/SdXLm8ube1lVh6PS9X8r3SegEJ F1dOfiVvbHV0FkaUZfZ0sk5yhTdEtRXeSzz7kFys/w5VO6fr40tjFmpJ8zjdCsWeM9KZ o80Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194816; x=1795799616; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GNutknphZQYW/QLgcDhW3Ed6+xGQZtXRUfm12mKXV6c=; b=2Yq9c1DRqMcZZWxtk2cOyaJDKoEImEPlH7Xg0e3pK2+OnDWx0Wk3Wms0RFmtVmsyra Q0pXXu9YxXWIik7hqe/eHCZXwFzNRNI1UQfg0vPIe9eokabhLNBOJna/MnCXwYHRfMbt eldIZD7XIGv2VxXpy7Gmmp0aF+Keuz6X+udpLns/ooWz6MmGxG6w7rHYHLZhKrw49x0o iAJWlJciYO5x1wB4ndCVkJjtDt+g7OKsGODxRrtrogmdwhDDHfvXpNa1AnBlwnvODQep CvprofnsrPEU/ezm9rh1Tvb6A68ZVk+4AQngkpcp8tBZGPqdeOACfQlQOdFKMBmfXEUC dzwg== X-Gm-Message-State: APuU4Z8MhpAeH++A7pe2enEg9kw1gb82gXZbYC+5tGiPF95JExXlOaFR ttPz3O1tmnDEPuE54SR18ldWdBtW1of3r06yEnYOM90Six8hMJlmypfd2z3GGFn649FB1lmRAUd HvozLk093t7fPQbLtCpSoITVxIuM/Os2SxzSLExtcz+RDZ6EEQxeL0yRUhBArnIHbsg== X-Gm-Gg: AYBFou0e+Rjh97ufI4nFQYAu7FsyBYNJrxFBtJ3OP5aDn6D8deFPukzic25JNuVKeFr FJaXzANTkp5xLwixnktZi/IKO1SDzhXABBtD+IfGY8UBbQxi6yNALk6/wAfRPobqCCax2V0xq3c Ht1+iQszsBsccnzCM9YNJwW2s/IelSNqTKP93x1jkwKLfndjl9+THdKGzYwXkXRi9JHWHMkX6RP ALz09UIk2b2zx1JcElxFyDwjf1RbCzFJBL+z3TLrFPtcL4juCbiEwGU8RRqWUBzBsyQ5+0AIBL9 /Jm7Q3XWZxNbXbH0XF+nH5uvp4sub7FYjs8REYh6BSDF+/KfNIjmGZEWcAD3sOK5AKdh1MWmeqf 7Wx66o4y68pNvTSG/8T+oZtJjohUEA7kHj6lN8L1xJuz/J+FHKZRvSr7e/3XTNmh/+Z0CoxNR5U vZWJ8XClKjl+uTlw== X-Received: by 2002:a05:620a:480b:b0:949:3017:1f91 with SMTP id af79cd13be357-949bab23b74mr601322085a.48.1795194816109; Fri, 20 Nov 2026 09:13:36 -0800 (PST) X-Received: by 2002:a05:620a:480b:b0:949:3017:1f91 with SMTP id af79cd13be357-949bab23b74mr601314185a.48.1795194815452; Fri, 20 Nov 2026 09:13:35 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 08/14] hw/scsi/ncr53c710: Deliver completions from bottom halves Date: Fri, 20 Nov 2026 18:12:28 +0100 Message-ID: <20261120171235.61325-9-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=FJaOVOos c=1 sm=1 tr=0 ts=6b007fc1 cx=c_pps a=7E5Bxpl4vBhpaufnMqZlrw==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=pfTFL2jsI9KnObYQJNEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pJ04lnu7RYOZP9TFuWaZ:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXxHsRHIrQN1uZ 9gfMsiCGM1AKdxAOht+oIsVTYrnvbAvoQrMh2d7Oj6j0i6JBBhrDnfZYS+zCMnWSD31PL7xyWR5 ZlcwsoFgJ4PakUF7rku459bFv7WTwxA= X-Proofpoint-ORIG-GUID: ZRae8bWnAq3x2lIUgPGDRy0Ra3lXy7pa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX8S95gj4DxQ7q c13wmJ8TDusvUw3n2BXcIwrvT+wXpLwcxgDGS95kOaWWdUIR7Zy4pLHTDh7FNWeF7ITyJPEZW5M cTrk7Q0ASZDJbAm5sZ9WpTJ1LtEBGSDfCvF5qilEw8G/aGTwBMWsyE8oi2V1EStAi1s3DrgCCfl xQGPKyk01eEmyEm+rSc7aWR07FZ2HS98/PBrRBpk44V8Fv1G4c8Eh/NbFvizBcUbjEHR1pzt43n tBuTFPPSzBfF35FItsot2OkT53vI6LToc4EtXpGD1CrSncQBGzYSabQoQr0G6EFOFfWjFB6Ls3y aJx161I4Gv9yFFX0LYXKvj+Sr5D3rzcTzHYZQnwZNwr6RQobReHblzbn++KtPGIRwAwZv9QiW4K ZcRBoZBhBzENtQnFix/az0GXQbLsW/Tu7cGzGmah/mGIfZWUwlqYocveedsXUER0hLq2z2QXb4x Ykcso2ij+1Wf7R1ZcYg== X-Proofpoint-GUID: ZRae8bWnAq3x2lIUgPGDRy0Ra3lXy7pa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194919007158500 From: Keith Monahan Completions are delivered asynchronously, as the real chip delivers them, rather than reentrantly inside the interpreter: a reselect reconnect and a tagged completion off host cached media (the install CD-ROM) are deferred to a bottom half. A reentrant completion would collapse the disconnect and the completion interrupt into the one guest MMIO write driving the engine and race the HP-UX 10.20 c720 driver's completion bookkeeping. Untagged and polled transfers keep inline completion. A SIGP kick that lands on a stopped engine, rather than one parked at Wait Reselect, is held in sigp_pending_resume and replayed once the engine parks. Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.h | 8 ++++ hw/scsi/ncr53c710.c | 92 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 90 insertions(+), 10 deletions(-) diff --git a/hw/scsi/ncr53c710.h b/hw/scsi/ncr53c710.h index 82202940caa6..8b5cbfc135e3 100644 --- a/hw/scsi/ncr53c710.h +++ b/hw/scsi/ncr53c710.h @@ -93,6 +93,14 @@ typedef struct NCR710State { uint32_t select_tag; int command_complete; bool script_running; + /* + * A SIGP arrived while the engine was halted instead of parked at Wait + * Reselect; the Wait Reselect handler consumes it when the engine next + * parks. + */ + bool sigp_pending_resume; + /* A SCSI continue was deferred to lsi_issue_bh. */ + bool issue_pending; lsi_request *current; /* Disconnected tagged commands awaiting reselection. */ QTAILQ_HEAD(, lsi_request) queue; diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 305958b92f4a..b9ebeb4d96dc 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -73,6 +73,7 @@ static const char *lsi_reg_name(int offset) static uint8_t lsi_reg_readb(NCR710State *s, int offset); static void lsi_reg_writeb(NCR710State *s, int offset, uint8_t val); static void lsi_execute_script(NCR710State *s); +static void lsi_issue_bh(void *opaque); static void lsi_set_phase(NCR710State *s, int phase); =20 /* @@ -106,6 +107,7 @@ void ncr710_soft_reset(NCR710State *s) s->select_tag =3D 0; s->command_complete =3D 0; s->script_running =3D false; + s->sigp_pending_resume =3D false; =20 s->scntl0 =3D 0xc0; /* full arbitration */ s->scntl1 =3D 0; @@ -272,6 +274,25 @@ static void lsi_bad_selection(NCR710State *s, uint32_t= id) lsi_disconnect(s); } =20 +/* + * Deferred half of lsi_do_dma()'s SCSI continue. It runs on a clean stac= k, + * so a cached backend's completion cannot arrive reentrantly inside the + * SCRIPTS interpreter. + */ +static void lsi_issue_bh(void *opaque) +{ + NCR710State *s =3D opaque; + + if (!s->issue_pending) { + return; + } + s->issue_pending =3D false; + if (s->current =3D=3D NULL || s->current->orphan) { + return; + } + scsi_req_continue(s->current->req); +} + static void lsi_do_dma(NCR710State *s, int out) { uint32_t count; @@ -314,7 +335,21 @@ static void lsi_do_dma(NCR710State *s, int out) p->dma_len -=3D count; if (p->dma_len =3D=3D 0) { p->dma_buf =3D NULL; - scsi_req_continue(req); + /* + * Defer the completing continue (dbc =3D=3D 0) of a tagged transf= er to a + * bottom half; the engine parks at DMA_IN_PROGRESS (set by the ca= ller) + * meanwhile. + */ + if ((p->tag & LSI_TAG_VALID) && s->dbc =3D=3D 0) { + s->issue_pending =3D true; + aio_bh_schedule_oneshot(qemu_get_aio_context(), lsi_issue_bh, = s); + } else { + /* + * Complete inline for untagged transfers and mid-transfer + * continues (dbc > 0). + */ + scsi_req_continue(req); + } } else { p->dma_buf +=3D count; lsi_resume_script(s); @@ -417,20 +452,43 @@ static int lsi_queue_req(NCR710State *s, SCSIRequest = *req, uint32_t len) return 1; } =20 -/* SCRIPTS Wait Reselect: reconnect a ready queued command, else park. */ -static void lsi_wait_reselect(NCR710State *s) +/* + * Deferred half of lsi_wait_reselect(): reconnect a disconnected command + * whose data is ready and resume the engine. Does nothing if the engine = moved + * on while this was pending. + */ +static void lsi_reselect_bh(void *opaque) { + NCR710State *s =3D opaque; lsi_request *p; =20 - if (s->current) { + if (s->current !=3D NULL || s->waiting !=3D LSI_WAIT_RESELECT) { return; } p =3D lsi_get_pending_req(s); - if (p) { - lsi_reselect(s, p); + if (p =3D=3D NULL) { + return; } - if (s->current =3D=3D NULL) { - s->waiting =3D LSI_WAIT_RESELECT; + lsi_reselect(s, p); + s->waiting =3D LSI_NOWAIT; + lsi_execute_script(s); +} + +/* SCRIPTS Wait Reselect: reconnect a ready queued command, else park. */ +static void lsi_wait_reselect(NCR710State *s) +{ + if (s->current) { + return; + } + /* + * Reselecting synchronously here, inside the guest register write that + * drove the engine to this Wait Reselect, would deliver the command's + * completion interrupt reentrantly. Defer the reconnect to a bottom = half; + * the engine parks meanwhile. + */ + s->waiting =3D LSI_WAIT_RESELECT; + if (lsi_get_pending_req(s)) { + aio_bh_schedule_oneshot(qemu_get_aio_context(), lsi_reselect_bh, s= ); } } =20 @@ -930,9 +988,10 @@ again: /* * Two things release a Wait Reselect: SIGP (jump to the * dispatch address latched in DNAD), or a disconnected co= mmand - * becoming ready to reselect. + * becoming ready to reselect. A SIGP that arrived while = the + * engine was halted is held in sigp_pending_resume. */ - if (s->istat & LSI_ISTAT0_SIGP) { + if ((s->istat & LSI_ISTAT0_SIGP) || s->sigp_pending_resume= ) { /* * The SIGP divert is a one-shot: clear the latch so a * later Wait Reselect does not re-fire on a stale SIG= P. @@ -940,6 +999,7 @@ again: * auto-switching. */ s->istat &=3D ~LSI_ISTAT0_SIGP; + s->sigp_pending_resume =3D false; s->dsp =3D s->dnad; } else if (!lsi_irq_on_rsl(s)) { lsi_wait_reselect(s); @@ -1404,6 +1464,17 @@ static void lsi_reg_writeb(NCR710State *s, int offse= t, uint8_t val) s->waiting =3D LSI_NOWAIT; s->dsp =3D s->dnad; lsi_execute_script(s); + } else if ((val & LSI_ISTAT0_SIGP) && !s->script_running && + s->waiting =3D=3D LSI_NOWAIT) { + /* + * SIGP while the engine is halted on a just completed command, + * not parked at Wait Reselect. Clear the SIGP latch, as a Wa= it + * Reselect consumption would, without disturbing the pending + * completion. Remember the kick so the next command is selec= ted + * once the engine parks again at Wait Reselect. + */ + s->istat &=3D ~LSI_ISTAT0_SIGP; + s->sigp_pending_resume =3D true; } break; case NCR710_CTEST8: @@ -1535,6 +1606,7 @@ const VMStateDescription vmstate_ncr710 =3D { VMSTATE_UINT32(select_tag, NCR710State), VMSTATE_INT32(command_complete, NCR710State), VMSTATE_BOOL(script_running, NCR710State), + VMSTATE_BOOL(sigp_pending_resume, NCR710State), =20 VMSTATE_UINT8(scntl0, NCR710State), VMSTATE_UINT8(scntl1, NCR710State), --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194872; cv=none; d=zohomail.com; s=zohoarc; b=eL9HvKc9rmLme6XYhjkCq2bmTNBT7jgIJ2+HGVXnC8LnaQisPfaXDzCKnJWsPIbyqvot5WdRI9/I1hd5yUSPVfZGN7pz9WyT1IoSKV8DACsee8lS36+45ulBObGYTrnhwq6FvufRldPJRzgtSFNCbxnFUsK8a2qqsuuh3MKaOr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194872; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W3D2SEpfTFFAxEC6P7Dd3RXFNqOszp22BZTmv4IHdtA=; b=SBvgyc1AfmsKWh46AzhlZVXzJE1e950tWv3lzVItE137eCiNE7JxbGGy0aWJutzcR0xiCzh1DeXsywq/OMuqeX8vNKsoEjGMI+9428tbfR65yBxJhUays6OJqZSFrK+rvyHh4oV6RCbZI3TfDiO3OAKS+Rx8M/+I+wRMD+jYi/M= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194872377890.6223592675958; Fri, 20 Nov 2026 09:14:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBn-0003zV-VQ; Fri, 20 Nov 2026 12:14:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBG-0003MU-S9 for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:50 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBF-0003uM-7W for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:46 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfIG12040039 for ; Fri, 20 Nov 2026 17:13:44 GMT Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjttxx9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:43 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-946038e22f5so249135685a.0 for ; Fri, 20 Nov 2026 09:13:43 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a67fe48sm6042565f8f.23.2026.11.20.09.13.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= W3D2SEpfTFFAxEC6P7Dd3RXFNqOszp22BZTmv4IHdtA=; b=pxugjxJ+jpnj6EIJ Ss2QfVqDknZ7U4CMKAuYEuB2evMhWs14aqmSR/Pt0UJnBBtvmB1O6vd9TixC9Mw6 RXwug0jAq2NUfpgpz3Kq287AkTrlkoMp8B3tGiD31LwNi2Kqzq0JcinkQxs0lqdQ Fw33BWmB8+mKRzTqz5IS2/0p3854vhegd2+boMRjws5rnAFmGTUqg4spRoMzYFgf 2Z9ijCWzd/psq7SY9AhyJ/bsyyzgs4dj6LyaUmQRMtZLRlJdd/aj2eBUgw7KZ5wU 25aCuhWUrhS8FUZKfGCu+ZfI73kVpSOZWKO96bPI/XOQAMfupoYnRliSCOYYWw2y t3cICg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194823; x=1795799623; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=W3D2SEpfTFFAxEC6P7Dd3RXFNqOszp22BZTmv4IHdtA=; b=GPpwIFQ6fWYerhhNmn1jCtjMSOASMgmgUi40LorATMPTuPL3zCpDWfieFnkuo2t64K YBxwpYJpuJ7nA1cf0jQXTTb/FUzRRzLiaYh8KWB0ceWOpFf0olk6+aORF5oMypEK1ljT D0mBShKAVRF3FLJouIg5XN9ij0gF4zOSiPRoIRor9rcLB8SKHp9KGfSOKaKiGvh5fXfW ZTmA0hfacT9Ug3JXynqRy2Ys0SnCxlCp61h0UMWfKuqibCYKURlgPf57CoZogiqYN3f6 KV2bRExoaNaDzAOaLfbWrp7r6RQ2HQCawtPFzlFF06u6PwZn8T6H3PveMZ9Ppk7lIwNg QmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194823; x=1795799623; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=W3D2SEpfTFFAxEC6P7Dd3RXFNqOszp22BZTmv4IHdtA=; b=EY9kR9RIBrGq8ys+q/7XWoIDvlNqOA1yyDDP1dKpfPaoSIh0ixL6yT5y2Ooub2XV6n 21x4CSuMavJXpjFICKqKTFo+nnk72QqhRkVg1qgQpNVAHIJBhAVcvOzS8s3EIPFSvUyB yaZk2E2P4Kt7M02mxf0BEK/4FjHT+osGzDQUz8uat1qZdSk4jaKk/cLjRvt1W6l8dIux zl875MyUtMa3OaIg/CxcO98axhiOIlV+pcl1Mp/S1YxskcmkB2q06idvFkfunukE29dK p0HXNxRE0Az/dMX0jXpOHcFRJJqdG2pvbglpg9treNP39rExRaGcdpGEpcEQDqsP7eIF +kZA== X-Gm-Message-State: APuU4Z+P3r+9yxygFMdRYVAp9GFqQ2BoWNtjj2MfnTcrRiooOSkgDKGQ PGMlb7QUzT5RdWv7ixx7KsjQz0L+NPsAL+R3IlqrnBQyQ+5+j3/D5B4zwQFvUng5ErXyivTG8D4 QlO/B5NAwlMqWWZStjETWnyCdn9O4hxp8EthVR3cmVwIoTdVdudwfTcqG2Y2QyvDOBw== X-Gm-Gg: AYBFou0rw8aJuY39pyOyc2tbCCLWUu1Yzhw/AzeAJxMx9a13yup3uKxcLqgBYGcmJuE vZOJR2hDElZZg2fNbRTQC8iyfklzIr64/99atnpGsn8qDDY+SQvOM9KgkJyg4jL5seQcwSIXwl5 46/AaVCdw2PB+YifOqHmubel6LSrqEe6dp5NIWs8QDk+xfwvTKZap4ZNV9d0/ZVVT361WQN2VRf 2vT9XgeFeOJ6doAtcrFkibugr8k6OG24mbiqzD66McQWHwmb00uLtJM8ox4X0ftXT2W0JNwhmeW HiGcEEVVL0AxH1AVBJ2x1L1upLE4CwfSBDeNmLomCZzeoKl8RCRWx4gROrRcDKdHcbogMAls2zV jIz5vjzWzVrtegm8BkFFj8YgOITiChvGHX/8OkdcIpfgCRLCzrbwlC0jvJeDCekPGfgMiRfrP3/ rAmIUn1lJW+du7Ng== X-Received: by 2002:a05:620a:8804:b0:947:b201:fafc with SMTP id af79cd13be357-949baa043b6mr542704785a.39.1795194823077; Fri, 20 Nov 2026 09:13:43 -0800 (PST) X-Received: by 2002:a05:620a:8804:b0:947:b201:fafc with SMTP id af79cd13be357-949baa043b6mr542700185a.39.1795194822542; Fri, 20 Nov 2026 09:13:42 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 09/14] hw/scsi/ncr53c710: Drain asynchronous transfers in the register write Date: Fri, 20 Nov 2026 18:12:29 +0100 Message-ID: <20261120171235.61325-10-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: gnh0TnHPcYnR5RuEVEdaP8KgdeEbgczG X-Proofpoint-GUID: gnh0TnHPcYnR5RuEVEdaP8KgdeEbgczG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX3E08zJ1Mtet6 Sc0r1vd3oLHnMtPEay8zQ19laCQ7BEMWzPP8PdEiCxffYsU30PvIgM1PpbLwggXp9d52I3Ocsyw tSXlGGDb5inPuLoWAen/a9N0GuGIAVR3v9s+0/H6vlI1oReBY4hlvzgPlWdIaaq7z24HuE33/9N PONMdvUEuqFNDmmghnVWnMrEKCuWXFUW7TH0p4usG79K9jiMD3OALtdxyx7CMJbqzHUtgtrBAIp 1C3sx+hlUK7v5YhvhvLVp7UsakOOnWkzlC2wihkyFclh+2XGSADKLUXYCkKl79TTb007cJzi/ns b/JGdAJq4eQ09GIroPiXadC8uMVNFI5Ei8EvdTjKd4Wp43kuYqEu5XgRVeqq/wsfYiPMqTEwsBe fpkNmTbEyFCcft3j+h0WqTkZcyGIuNE7CxTntu9/14xZ0FsVcsFxJ47Oz4pTpI81CUab35bfUly +NY4f8DbHAvnKGat2vg== X-Authority-Analysis: v=2.4 cv=XcccX455 c=1 sm=1 tr=0 ts=6b007fc7 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=Ld5TIVOHH0keToIO5T0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX1It+8DDi3uv4 1eCxJ/uILjzTv6QA+YzqsIzLZ5NneZjQnirQwCxa+YCnNLwUoCao2+E7S3+Tpxh7iVoY2eJ/dMy YvWXq26mDQb8M6A3n19DUizSQbqXkSQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194874521158500 From: Keith Monahan The c720 driver of HP-UX 10.20 needs the completion interrupt ordering hardware provides, starting a command with interrupts masked and then spinning. So after a register write starts an asynchronous transfer the model drives it to completion before returning to the guest (a bounded synchronous drain under the BQL, as IDE and MegaSAS do, falling back to asynchronous completion if it cannot advance). Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.c | 29 +++++++++++++++++++++++++++++ hw/scsi/trace-events | 1 + 2 files changed, 30 insertions(+) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index b9ebeb4d96dc..9ca025ff6334 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -53,6 +53,12 @@ =20 #define LSI_BUF_SIZE 4096 =20 +/* + * Safety bound on the synchronous completion drain loop in ncr710_reg_wri= te(); + * it then falls back to asynchronous completion. + */ +#define LSI_DRAIN_MAX_ITERS 100000 + static const char *const lsi_reg_names[64] =3D { "SCNTL0", "SCNTL1", "SDID", "SIEN", "SCID", "SXFER", "SODL", "SOCL", "SFBR", "SIDL", "SBDL", "SBCL", "DSTAT", "SSTAT0", "SSTAT1", "SSTAT2", @@ -1552,7 +1558,30 @@ uint64_t ncr710_reg_read(NCR710State *s, hwaddr addr= , unsigned size) =20 void ncr710_reg_write(NCR710State *s, hwaddr addr, uint64_t val, unsigned = size) { + unsigned drained =3D 0; + lsi_reg_writeb(s, addr & 0xff, val & 0xff); + + /* + * Drive any asynchronous SCSI transfer the register write kicked off = to + * completion before returning to the guest, so its completion interru= pt is + * raised first. A deferred continue (lsi_issue_bh) has not issued its + * backing I/O yet, so pump it inline; otherwise blk_drain the backend. + */ + while (s->waiting =3D=3D LSI_DMA_IN_PROGRESS && s->current !=3D NULL && + s->current->req !=3D NULL) { + if (drained++ >=3D LSI_DRAIN_MAX_ITERS) { + trace_ncr710_drain_exhausted(drained); + break; + } + if (s->issue_pending) { + lsi_issue_bh(s); + } else if (s->current->req->dev->conf.blk !=3D NULL) { + blk_drain(s->current->req->dev->conf.blk); + } else { + break; /* nothing deferred and no backend to drain */ + } + } } =20 static int lsi_pre_save(void *opaque) diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index f0eb1457022e..843d8f1a1e27 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -340,6 +340,7 @@ ncr710_memmove(uint32_t dest, uint32_t src, int count) = "MOVE MEMORY dest=3D0x%08x ncr710_do_dma_unavailable(void) "DMA: data not yet available" ncr710_wait_disconnect(void) "Wait Disconnect" ncr710_illegal_insn(uint32_t insn) "ILLEGAL instruction 0x%08x" +ncr710_drain_exhausted(unsigned iters) "synchronous completion drain gave = up after %u iters" =20 # lasi_ncr710.c lasi_ncr710_device_realize(void) "Device realized" --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194883; cv=none; d=zohomail.com; s=zohoarc; b=MG0g+e1q0ITsA3rNPqwbj3iepUtn4asbAdpYLhNK53AHLhD8nGW768iSedBD9BRkgGHpkG/k07KRrYdfLheMleMnSHGSvNyfD2r2+29JvsD0U5njnQPBySpP5X5++qgg5lS6OqTNc8QBnM/+kEMfXjOtIZSJ4Kwp3eNrCnWvxYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194883; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IUS94AHKdQNLJ61rfRyuLdV5pXwveMdl6S8QioZLG+8=; b=SqT/XjPvvnBpSYvgj+sd/zxkfs1hmfD4aUhzzGd94oSBauTLAbqdUvGhEZUm7iQ1yhwxaeKmeNPufQq1/S82zAZWuq//mhn/I4aN5xX8n02pgZIWEK0YGmwfoZ8HcH0RnDupuG3bDtvsaZpRZPh57fPnuDppCOQSe9NCUca0+hg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194882948937.0039424219941; Fri, 20 Nov 2026 09:14:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSBb-0003kP-Fv; Fri, 20 Nov 2026 12:14:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBN-0003Qp-JF for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:56 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBL-0003uu-VD for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:13:53 -0500 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKGFtQL3830233 for ; Fri, 20 Nov 2026 17:13:51 GMT Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2sjwg7kg-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:50 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-94961511b61so203377985a.3 for ; Fri, 20 Nov 2026 09:13:50 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6bb989e3sm7038401f8f.52.2026.11.20.09.13.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= IUS94AHKdQNLJ61rfRyuLdV5pXwveMdl6S8QioZLG+8=; b=IxasUXWaBMBYTTUR WV5hdSysQZz945XnoVvPp8Iuov0wC2TxYZa8qi8AQs1fDXA0ap29ubzd7aeHz07J zBuGWuQxAa3V7m9y9snfkbnp3qDNQIs+zRXfPU4vSgqljxyW9zvllsd1W7FE5VZA fkS+9MF5QYnxnmvrmga/TeR4yYaPsMDi4HbH4n3UQ+cOsjv9MdBHrRNmhCXt3h7y SS/BwgQM7kn/KlKVXkSrUenJjGiP14QYhyLNWa4IBXvAsnL8QCmbVWLs7ccdh7zy HUoEibsiajBzwTe0a8FfkxKgeLDhrkLNdOpD8v93D4Mc3y1t/PIOwLcf20lez3qz Q//K2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194830; x=1795799630; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=IUS94AHKdQNLJ61rfRyuLdV5pXwveMdl6S8QioZLG+8=; b=aSFHeAZSltKH0rWyTrpJxbVxWlelhUbu6YPMUXNRuB1EF6u4TkioyvQF9dqeNnvKc+ QUo6jocJ0vgyn195ThcolQBNTDx3EDndJZ9M0+rFkrJEsvVPlWa7tSfZM+H8tB0yaayn wv7HCmdxsLZL3KTX5HMcDNQClWcGu59J3VMsxnWvijzGLr6S4Fl+ny28MxgQ2h4TVb4Y zwlIFWy6KnY9odShGW9fMe3z43A285NyOv1ruWZZo69WAepE5HufypDTDesZC2dVSMSU fXxxlbtbNGVOCsi4i1qeMcQjk2mL1XZGeMcu0GY3MDLW1t8JXp0iuuQu4X15AD6hpQz8 JxWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194830; x=1795799630; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IUS94AHKdQNLJ61rfRyuLdV5pXwveMdl6S8QioZLG+8=; b=kOti+yyMBzC95pBVfb5Fjtj/FWbbm6eCjdWBO27s+mHpIwmXszHnoPXa5cYoIoqwgs sI6ny3i2UGkllB6v9dbuuCTuWRsvWZuLIC05yteSUqK8K8sTOT+0BNk3N205ulQWceWE JF2P/BLt8hMP7lG2WSP0wgMwjH7I/Xcv7hwrnckgG5f5J2lnucdZ9XWLyvH1MdQYRukc gSEgCTezDChPELXxCfHOANKzZ92AGrQ8ECKDAnHuo3ZRRbS03WX/dn1T9toJMvhBGQW0 ebR+0pWuooqUPWl4Dxpblt3fgdifQYqrdK2Fgz+c/oiXsfvjzXSHIbHSJKFYXtDh/xJ4 w1kQ== X-Gm-Message-State: APuU4Z9Jb2bmNBkF7xIs2hLZTFE3PfsnPiJqMsBerg87fVFrwzrmeLu+ dwgT0PwlPKAGImoZ9I+sx/JF+BcnUk46TlfZzsITaWo0a0Pnp99+5CmJzJV3KKjLtos46UeY+sn glSZUMUHV1TolgtUlj9Ao7CnnwIxpNpvZqJwKzWQn2xGJ6HN7Pl2fQMVYo2lyRLK+pA== X-Gm-Gg: AYBFou0nu64JLotmw9w8QMwqTSG+CeAMqMh4e7+XG1jDvSx4ADG1c3qSji4dzSp/Z+c c6hJu1EFlwX2QnOoHUftZTFg1yQMiLP+aVTMVvGnHUY0+N01FsadnNw2Wq6/TDDStDeHWhBmw0m Q+xeEFIp+CDBZBplFgv/SzXlErcZ3ViooCoMZ44e6+4NJryHMYFoE4XODLEcwF2tbxa53QNZnkp XMxIi8ZOjdBh/YLw+DygZQazudzlP+n2Ho7JVlNCwqF39hrURkRUtPWJ9DlsM8/TE1fg/J5R3uS T0w9cuZGeHGfD6GLKAnC2BaiUhUftccNs8IZZdgHBPn5jAVRAkeYqxm4hYMIFsaWzfDwEJRGaI4 X4WRdlGkQF4CVZcjaWMfsmlxADhron99K2Dur+Gy1oEze9q4jXy3ZW3JLaxRiEliss2k41pBOg4 qSJBuVU5SGNdl4RA== X-Received: by 2002:a05:620a:6892:b0:947:7691:7316 with SMTP id af79cd13be357-949bab3d3bemr598921285a.81.1795194830158; Fri, 20 Nov 2026 09:13:50 -0800 (PST) X-Received: by 2002:a05:620a:6892:b0:947:7691:7316 with SMTP id af79cd13be357-949bab3d3bemr598916285a.81.1795194829688; Fri, 20 Nov 2026 09:13:49 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 10/14] hw/scsi/ncr53c710: Append SAVE DATA POINTERS after MESSAGE REJECT for HP-UX Date: Fri, 20 Nov 2026 18:12:30 +0100 Message-ID: <20261120171235.61325-11-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: P5g7PFB_kbHMeI9DmfFx_oaSrchYdi7m X-Proofpoint-GUID: P5g7PFB_kbHMeI9DmfFx_oaSrchYdi7m X-Authority-Analysis: v=2.4 cv=dZ4VTnXe c=1 sm=1 tr=0 ts=6b007fce cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=9Uk40hKUNlF1tgaBGToA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXxa6mWHTSPFaf GmdX5xvqC10bnb3brwcsHtN3TDE2jZ9DsPBS5CGWKTExab3iE5O4bK/XXlEoQfGSjVngcyBPVHZ mcrNYpN8cMri8EHcChapoO3bV3/0eNc= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXwG6+DnUNbkJ3 TwrEkFkPfL81CCMVr2SIJ1NeK+PjQs/jke2jifqA0nn9MlrPK8G8seosd9uZuvoNCOQ12Vm5L5C jdRYlmmVYoA5eqLnDa9hlo4/C6m/aXFOyoOp14DVTkLffmf1t0dDd3mF3usQVQdEuFJRB+wJXAY DabBsGgPfZEdP6OsKRPVMOsMs8JERVmL5TW/+VlvQVzUyk6aPU1oB6Z30Tz7a9Q3qUFjyO8H/+8 siYi0U/VSk7X7aGLDFFWscg9XZuZuyZRudkh66cTc7MEpzG9euZsozfNy84jJsBq1irk5Z9j3tV wdTlJvfDu4J8B0FEs3WQ3iEq27xSMeO0bB5Yf2hpdz9gc5LOL6zQcnqU3L0lZZocv2Qwa9FPM1c UOd+v5nZ8n/TxJpl1JZ9JcW253CwlSg4gGmzeDJIYOdsoMSjL5dvS4r9DGB5hex/iegttABYSmZ uyTXLp2FQaXtxpiuRww== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 spamscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194884562158500 From: Keith Monahan The HP-UX 10.20 install kernel is nonconformant: its self modifying SCRIPTS reads a second message byte after the MESSAGE REJECT that declines SDTR/WDTR/PPR negotiation and hangs unless it is SAVE DATA POINTERS, while NetBSD's osiop resets the bus if it sees that byte. The two are told apart by ATN state as the reject is consumed (HP-UX has deasserted ATN, a conformant initiator has not), so the extra byte is appended only for HP-UX. Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index 9ca025ff6334..dfed2f2f9fdd 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -699,6 +699,10 @@ static void lsi_do_msgin(NCR710State *s) if (!s->msg_len) { switch (s->msg_action) { case LSI_MSG_ACTION_COMMAND: + /* A MESSAGE REJECT declining negotiation was just consumed. */ + if (s->sfbr =3D=3D 7 && !(s->socl & LSI_SOCL_ATN)) { + lsi_add_msg_byte(s, 2); /* SAVE DATA POINTERS (HP-UX) */ + } /* Stay in MSG IN until the next block move requests COMMAND. = */ break; case LSI_MSG_ACTION_DISCONNECT: @@ -794,7 +798,12 @@ static void lsi_do_msgout(NCR710State *s) } return; reject: - /* Decline SDTR/WDTR/PPR negotiation with a single MESSAGE REJECT. */ + /* + * Decline SDTR/WDTR/PPR negotiation with a single MESSAGE REJECT. HP= -UX + * requires a trailing SAVE DATA POINTERS (0x02), which other initiato= rs + * reject. HP-UX reads the reject with ATN deasserted, so lsi_do_msgin + * appends the 0x02 only then. + */ lsi_set_phase(s, PHASE_MI); lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */ s->msg_action =3D LSI_MSG_ACTION_COMMAND; --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194901; cv=none; d=zohomail.com; s=zohoarc; b=YByoqj3KFesUvBjGO0/kALZJoCRT7V8En8vP1BsepgEZBJf5w8sGIiV3aYbKTSwqs34Bg/UFi3oZUX1iDh2myrnWXZY4ZNijlpzuDK6/wJIVitbEEfTTKdv6ue52zsEWDBbFVRXKvrPWqDrOqUkRnPiIkAmnz8bvze3P+GFKq3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194901; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AIwReEw76AJoywthnrMOk9P1NJhW8jJ6Vw67ozqqJdQ=; b=nbUEKaMfUlT75Uah6KZZvWXjOCUicEvIpeLqqUom4pgNXGjLgF3bKUMW30lu6tEZZ8MrjcMQgnYQCZ0PSLtJJtEn8xRO3N5yqk6CEU0l/xdJ0Ng0ziZHtve3abGU+VmN/DCuSn2Rke5f0P3A51i92aMwo5znJ99GEClmvOrADbw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179519490189535.84230461841173; Fri, 20 Nov 2026 09:15:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSCP-0004hL-I0; Fri, 20 Nov 2026 12:14:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBV-0003Yj-Fc for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:02 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBT-0003vk-8R for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:00 -0500 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKH0dE11882443 for ; Fri, 20 Nov 2026 17:13:58 GMT Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2t7vg1y5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:13:57 +0000 (GMT) Received: by mail-vs1-f69.google.com with SMTP id ada2fe7eead31-7b206156cc6so715079137.1 for ; Fri, 20 Nov 2026 09:13:57 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb88442693sm90547225e9.1.2026.11.20.09.13.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= AIwReEw76AJoywthnrMOk9P1NJhW8jJ6Vw67ozqqJdQ=; b=FzMQWO1OQw0pLMbj VMyQa8K8OKc6kvxeMtBEpOLwd507ZSYS8oJQIaz4mnhjEiVq4TrjT7f0AZFfx+J+ bQCCwneOKZz9V8O27gCEDOAHdEasVTmf3Z/FcUUZB8+DPFROP/JfbgvTNMiYFDYx HyIRYVQpkb2pb33GrgOSLa8X9DZH6+4QYJh5Vy0++Mghqm1rTZEEQY3UhBrfsLYl Jw/Y3RWjyuHHssD6iPmWCFSKvxBjemOC1WKF6G5R01glviopTovor5OJ6oA7c2J+ K2nl0RV6nbl0Cq386Z2RP1YMQVYxVmjpbyNk1zwZtVBU4hmk+W0sz/xJusy0EKlK 8ooDsg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194837; x=1795799637; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=AIwReEw76AJoywthnrMOk9P1NJhW8jJ6Vw67ozqqJdQ=; b=PE/keB0EjxtWU4SSJLuoq93fal9rxQ8GsEiWMVZbzngs1+R2sfGY36UHzQeplRVXEB s6IuBp3T2MRKd2S3APQa3yEEnXcbqo2WWF0GKY52oCaZyEl5mb8vSz/6MHLnawuMyx5g yNrph65pNmWdkcIBtFqFvouA84smV0mLFKa+rizWTdrIunFLx1dCZUcW8ehMPrTuUE4d Qz4APVPT93RDuwWMgwMhG4vy2iQI+TWcVUUW2LuksT2NHMYp//M5SwGtom9WHVEW0lR9 kPvSp4hlTxp3R6oxOZNAnl9KaFhb9Q94D8l+Ew7dAhLogye1iyt+Eij088NYrYn9Hi/n JSHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194837; x=1795799637; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AIwReEw76AJoywthnrMOk9P1NJhW8jJ6Vw67ozqqJdQ=; b=JmCdcqCDYSsf8jGGwKfNjVOcpkx/E3+1SXtsrG+AUzuWVlwZkzu0ouuQ/8O7GBVf9Q 5wdPaDwvAJ+59WNMoUTGYvUzHh6j5qn3D0i9nhTEiBaWrFCosTxzen7QhVdC97mo3bX1 3rSS52oFejeZR1qbw2i4Ykq//4tt1fkJJNtQjSKh3NForSDAdL3PUO04276ISR+U1Fo9 VuYp7q0DFY6GM/pHqTvaeOYmUZJjusEjKSRVvNQX9zKNG1cnkcpjrlkTNq2gq+PBRqXb D5F4EpEHu/jZuPoyHlQkMzjlGFYMSog8tDd3rYtt9tDP0IH1hjdkCq4ndytcVkGsLXdX cXKw== X-Gm-Message-State: APuU4Z+zlWAtLxx427jDVazmmChoK8wfo6qN+rpQsz7Wu4PAaon0LOs6 lsVvmzys/3HwxVVn2NSR9GP6vodMyozouob3pecF2fFqF/iqU0xtdWmiyxUZX4aCi3dOHvt0FoW 22+ujU1scucSZQpr/vSQ4ajOzdhfI0rCLCCKzBbCPS3poI9RKYcGNyOYzhHNrBdpQrw== X-Gm-Gg: AZFdTZdUOFGpr/pY/dGp/xRMLO21JNSVuKm16hUx04HNdyRMUnpe8VlW6rGwjwxZRPC U0wcrS0w35gnbF775jxbDuub7XNnJrHQu3Zf+aT+9THKF25RnkizTSYtfl25Wd4k47XZGC3imas 8FtfVqZhm6e8JVLqCRfFS6Dwg/mShjboAyjGpt+mk6/A0YRULmwlpJkhmYz2MAiNuUkxOStkak4 F1VLebXeZAWdRLAgT/Rn72XCoxGj2GrH0M3xUq1o24347YnxNZ12OJ1JF06iZ8FoE7BfUUuvSsp gw/yNkx1a3HmFtuo9/ZIR9sZKvJLwYnA3vv0viOy52Jvwjb1g7eR9zLfRSpxJuk7gQkYd1awCCT 9jK5QndQUiDkUw2MhT7GUDJe/eaXQgcV7tJM1CVivqqPGdUvj8y63HwR08BgRPeaqAJqiV/izWG TzQzVmwQSQl0S0Fw== X-Received: by 2002:a05:6102:b04:b0:7d6:6732:6ced with SMTP id ada2fe7eead31-7d739457b80mr2017778137.17.1795194837369; Fri, 20 Nov 2026 09:13:57 -0800 (PST) X-Received: by 2002:a05:6102:b04:b0:7d6:6732:6ced with SMTP id ada2fe7eead31-7d739457b80mr2017758137.17.1795194836832; Fri, 20 Nov 2026 09:13:56 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 11/14] hw/scsi/ncr53c710: Guard SCRIPTS reentrancy and cancel requests on soft reset Date: Fri, 20 Nov 2026 18:12:31 +0100 Message-ID: <20261120171235.61325-12-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: WYy9JhfFlql88CNNYNPSrc54lk2qGXHN X-Authority-Analysis: v=2.4 cv=BZZNQbt2 c=1 sm=1 tr=0 ts=6b007fd5 cx=c_pps a=5HAIKLe1ejAbszaTRHs9Ug==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=v_S-xQxp4mYtYP0rbdAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gYDTvv6II1OnSo0itH1n:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-ORIG-GUID: WYy9JhfFlql88CNNYNPSrc54lk2qGXHN X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX/twhKo6IXnvJ ne6L+tunuvStI6zxzWNzzbZ4KyNk90bDxcKTkTzXI2B3yW8cXFbmnx5/aPhH7+3vW14Ud1m0rO6 w5Tr5SJMAhFe2VScNHg1lDhbNr/hg28= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX7SlooS8e3b2/ VhG1yV66gYV5RuaK197jiRHFQ1b6vZfxES/KphtGvN+dXf/OCb1klfvtJ0dlrFaKJShhS6k0jPP 8z4IkhwXSjZp3ItwMRtqwbfHb7d4qWF38HyECbb6g1/ZaqLT1PXYTGBt2mTsgVVPHDO7fjhs5sz 8vulS/KLW8EUdrbQeag6VF+7JFBVQDE561dQRrCgHASBk5EyvKHRgKD4xW2xZqjU+AvCNcrEgvZ Ypu5Ywq6mYiNDajGYQISLl1xNzNQNZgjwJ/Wx9DetZbE/Ysu+AMp0hF8ihlZuflJme7SoUfoUYG Wf2/WCnCnr2eyzTIOSTrDWsZaD0LJrfxwKTdY44I1LXXfGhsnUGEURXItTBsN3U97DM59nykPO0 D4J8JXwLdQSuddH27TPZUfmfHrHbm4Obm9EDzri6bW8WkmwEA/jGQ/5DO7oRkdx1DB/XmKeJ4+B 3CGAQjTE/EsPTeyYyyg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 adultscore=0 spamscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194902737158500 From: Keith Monahan The interpreter guards the reentrancy class behind CVE-2023-0330: a completion that fires synchronously while lsi_execute_script is already on the stack no longer recurses, and a script that retriggers itself is bounded by a recursion depth limit. A guest ISTAT.RST soft reset cancels the connected and any queued tagged requests, so a stale s->current cannot dangle into the next command and queued requests are not leaked, mirroring the SCNTL1.RST bus reset teardown. Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.h | 5 +++++ hw/scsi/ncr53c710.c | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/hw/scsi/ncr53c710.h b/hw/scsi/ncr53c710.h index 8b5cbfc135e3..9a4816794e1d 100644 --- a/hw/scsi/ncr53c710.h +++ b/hw/scsi/ncr53c710.h @@ -101,6 +101,11 @@ typedef struct NCR710State { bool sigp_pending_resume; /* A SCSI continue was deferred to lsi_issue_bh. */ bool issue_pending; + /* + * SCRIPTS interpreter recursion depth; always 0 outside + * lsi_execute_script, so it is not migrated. + */ + int reentrancy_level; lsi_request *current; /* Disconnected tagged commands awaiting reselection. */ QTAILQ_HEAD(, lsi_request) queue; diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index dfed2f2f9fdd..f75540da7720 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -103,8 +103,23 @@ static int lsi_id_from_bits(unsigned bits) =20 void ncr710_soft_reset(NCR710State *s) { + lsi_request *p, *p_next; + trace_ncr710_reset(); =20 + /* + * A guest ISTAT.RST soft reset can land with commands still in flight. + * Cancel them so no stale pointer survives the reset. + */ + if (s->current && s->current->req) { + scsi_req_cancel(s->current->req); + } + QTAILQ_FOREACH_SAFE(p, &s->queue, next, p_next) { + if (p->req) { + scsi_req_cancel(p->req); + } + } + s->carry =3D 0; s->msg_action =3D LSI_MSG_ACTION_COMMAND; s->msg_len =3D 0; @@ -114,6 +129,11 @@ void ncr710_soft_reset(NCR710State *s) s->command_complete =3D 0; s->script_running =3D false; s->sigp_pending_resume =3D false; + /* + * Do not reset reentrancy_level here. A SCRIPTS driven soft reset ca= n run + * while lsi_execute_script frames are still on the stack; those frames + * decrement the counter as they unwind. + */ =20 s->scntl0 =3D 0xc0; /* full arbitration */ s->scntl1 =3D 0; @@ -257,6 +277,16 @@ static int lsi_bad_phase(NCR710State *s, int new_phase) static void lsi_resume_script(NCR710State *s) { trace_ncr710_resume_script(s->waiting); + if (s->reentrancy_level > 0) { + /* + * A completion fired synchronously while the SCRIPTS interpreter = is + * already on the stack. Do not recurse: release the wait so the = outer + * loop continues to the next instruction, which the completion has + * already armed. + */ + s->waiting =3D LSI_NOWAIT; + return; + } if (s->waiting !=3D LSI_DMA_SCRIPTS) { s->waiting =3D LSI_NOWAIT; lsi_execute_script(s); @@ -857,13 +887,18 @@ static void lsi_execute_script(NCR710State *s) s->waiting =3D LSI_NOWAIT; } =20 + s->reentrancy_level++; s->script_running =3D true; again: - /* Yield to the CPU after LSI_MAX_INSN instructions. */ - if (++insn_processed > LSI_MAX_INSN) { + /* + * Yield to the CPU after LSI_MAX_INSN instructions, and guard against= a + * script that retriggers itself (CVE-2023-0330). + */ + if (++insn_processed > LSI_MAX_INSN || s->reentrancy_level > 8) { trace_ncr710_script_yield(insn_processed); s->waiting =3D LSI_WAIT_SCRIPTS; lsi_scripts_timer_start(s); + s->reentrancy_level--; return; } =20 @@ -1209,6 +1244,8 @@ again: goto again; } } + + s->reentrancy_level--; } =20 static uint8_t lsi_reg_readb(NCR710State *s, int offset) --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194931; cv=none; d=zohomail.com; s=zohoarc; b=di5rfBwqp4R3W9e+dcK1dmc1oTN+DBXcF/T1M59vnU9V3KOzgocTN56OtpMS8q5OtTYIdMjXe3ewZamTZIrioNegV4tzvp6719i0dNTHQ9m6vV1htJbTRgxtidN3l78srkwdxuM8hWkccnGp20te1B31ZIN6n6Nk5QN3xh5JhPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194931; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dSk32GFV9w8KwAVkufxIR4tqPzxMljQ04C6vWgo8qes=; b=Y73H2KCwQC2E0GjIxefiZvl/+pjTOBBJ20CPF6KqOJMUarPGu/OXlDDFR8RXpp3GkyYQsRp9bWW4SMZwpkhoh/SaRjR8WTcwIH3cthKZRdPwhU/sVJzOnsJqplv/66C7O13NQ+qSH0FBpVLHMOoUMl/WkFiZ717sVZQcdOIVFFU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194931622840.9083559149212; Fri, 20 Nov 2026 09:15:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSCa-0004v6-Bs; Fri, 20 Nov 2026 12:15:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBc-0003oJ-32 for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:09 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBa-0003wM-CV for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:07 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfGI82039946 for ; Fri, 20 Nov 2026 17:14:05 GMT Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjtty02-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:14:05 +0000 (GMT) Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-9213e04641dso11705346d6.2 for ; Fri, 20 Nov 2026 09:14:05 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8538b2c5sm127297155e9.5.2026.11.20.09.14.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= dSk32GFV9w8KwAVkufxIR4tqPzxMljQ04C6vWgo8qes=; b=LPvCes3sTEuJxRUw /VB9SikIhGTJa1stiKFwLHRSIs4jdEnLN750YcyVFX8sane9PXg+mrHxV0u8IR2e 3e3pylFgfpHbsZG/wbie3bU7HJXVDX788y9nVfY5FLj+tdGS3f2ZjvFy4+MwBm20 Z9ZZic/JSHkVsaKCRDdNqRLvxQGvWLs/gMVXVbWRbYNpqTLIut/roTr1RCMTQB+d fiClXSC8WniAM3246PG+qaa//xxjj9xQ6klU2pTLBiBA1qHx12raCdErZxqDCaoX sEtv+DGrtOGfylEz76GGabgiFO7L2xlYO7zzSuB6e/dVw0DxzloaPMUfQwkKdm34 mRQeWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194845; x=1795799645; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=dSk32GFV9w8KwAVkufxIR4tqPzxMljQ04C6vWgo8qes=; b=EVP2HHde8YHMYeVQb117RPcOdKtCMxtQdvQUeAq3sv4Z/W35QAhqIw3qdzpi6Dmr+P lrADCcvA7BfDBkP4u5jxelJDEXPJ/amhqxwu2P38tQOBdbGNbMQBkSbNYPlB8C+1rzgK YK/twq6ieRrkPBN194akB5WBIZSXtpV3Smn+dPSPIud/oxsMnthMQ1sJu2t7dsvTIDA5 FCwrobUzthQVmpp5LHB+BGVG+/fMzrQPgSpjk6SZ623F09ztwMqaPzDJ5d+iK+sU8D20 9NWzyKis1DU+u5tVJltXPv1R1I6ZN72U5ThaxBL3uWPvE8lKNcIisCSPNvUifAACA/Vf jnlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194845; x=1795799645; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dSk32GFV9w8KwAVkufxIR4tqPzxMljQ04C6vWgo8qes=; b=ASvTYunG0KsoGbytlSTiaOHUPiNMzy0EuhHTtj5HmJKdSSaoFk37UznS6IB8265wiU US2RFpsXBBISYerGzlmspeMHtdgN6t3KkZpO1toEAiYGj9uAEfRLmjVdcu1OyBQUz+yi S8JkMadP+dd6mGp1XpSv1YoKVMMD4DFhrWBETC832r8DQe1+xccpOIc4KvIv3xJL4nIM /udedWS9M0wo6iIhoePGPPbbZfOLZc5vxGw6KC7efWKsv3Dxjex0tfDQFh1Sy6SkxeOr Ais1gfFa0pskkbAS7uhRopQsEYtD15W222nfutz47eG7ciunDNB3g1bEltu+OK9GNNc9 jnYg== X-Gm-Message-State: APuU4Z8Up9McWx8VJSbLRs4wLEXEKNDsXCyNHf6/G7SaHFWslB12igJ8 BNYIpZF82qGXXJttJss/77R98dS8WdSR+VuAR9jrePo+G/poOjGGEeicHGdyL9A8ibQZvelipIO EtXoqIMylyKiQsgj0zbrqpD/NBaaCLPvVPNJodv66pwGqBP4WdPFFuIzJSmENVSuZFQ== X-Gm-Gg: AYBFou3qJ37cApjvHZjf1QJMAQM47hAMu6vUzGWrNWWe16SlX1/7F703MRKjVYtfMkK 3nHwntfU1nYKv47q3b3bEQrRRbDOQuIQWFeBGryRpivZw3tPx4NNlg6B53QNgUi8dEXL8qBjc7Z WuI9T1WiPRg+D4+2WIFZDTvrXWIxYatkeSiZdf8r1swzglxRakD6DEEx4i0//elcoI6hnzEFPf8 EVXAUm1jKhUhOYlJf4cUwA2yV8AbQGG32Xkga2nrOsvMmWdQWBZ+pswVj4EgCM7mjAj181VgZ5Y 8xnB1rYx8GVmNFv5NEgoqqFcrNVvlwptToiKXZtl0tWHFPS3cEKR9F38AWJn7idOunAZpHfiOjS EWBR6WBvw3CpCWl6V7P7WlkL13/jtHaE65wCpyMQVGTn4SPihisxj3FN8qAV0mdsdAH2FLCZRiw kOyVbTTuLynxfhTA== X-Received: by 2002:a05:620a:4551:b0:944:d7b:e7a with SMTP id af79cd13be357-949baa0ce68mr600302485a.52.1795194844609; Fri, 20 Nov 2026 09:14:04 -0800 (PST) X-Received: by 2002:a05:620a:4551:b0:944:d7b:e7a with SMTP id af79cd13be357-949baa0ce68mr600296185a.52.1795194844032; Fri, 20 Nov 2026 09:14:04 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 12/14] hw/scsi/lasi_ncr710: Map the full LASI SCSI module page Date: Fri, 20 Nov 2026 18:12:32 +0100 Message-ID: <20261120171235.61325-13-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: kwxJihun8hz65rwMug3yWcxfCW0ncMt5 X-Proofpoint-GUID: kwxJihun8hz65rwMug3yWcxfCW0ncMt5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX9oPTYyqXXbod VGufYVpAZi1TQt/dn4x6xk8p+JtO9crfFV7TQ/iEzk6TYSjogcJ8WP8Fbp/iBsNSX/szhoka4aJ fLVNJUW98F1+UXCodhS5TOMRfeCPbAr9T33Oxom0y+SjGFPra4XkkUM1n+iSziCtKWUm2hQMHe2 3RPzHkXL+UwLP9u466mfXIOqvBqjcPow6bfQeE/RvcLoB7VYZsiYbnvaHhby2e/By+ayGfneqUq purYz2wDhS5GBn/Xs8Fz59WQ/IBy7BB0ZNnEifV7b61eGwtQ2ngGeR+htG0IyB/fxpZOyMOU6wh RWlui4iywvCqYrkTJkXOf/bVqdrYw8jvhr7OyfGIMP8CvDWP+k7Do5jTWlj0Z5JCbRG+5NAsSbk wNpVxKZLxgsx/5RHp+6s7tq9Uxx+qq9kGEHvTkrlkktuyy9MpmRX2gtCH3KjPqeIVvRdf6UkPhv E9kxA0J1vFGPx03sCtw== X-Authority-Analysis: v=2.4 cv=XcccX455 c=1 sm=1 tr=0 ts=6b007fdd cx=c_pps a=7E5Bxpl4vBhpaufnMqZlrw==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=n7BD_sn2foo_3xeKym0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pJ04lnu7RYOZP9TFuWaZ:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXzTmu0n+YhEa5 1IN0+FGeMb3IXRBKoVogYYsZy3I+NltFS7j0gE8/qH4jUAIcEmusgzQI4xkAbVqywzGutxy5Jgk eZ+c+H/n0rvZW+yKhDKsrNzHvaH2F4c= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194933017158500 From: Keith Monahan 0x100..0x1ff goes to the chip core as before. The rest of the module page reads as 0: HP-UX reads a board strap at 0xd85 (bit 0x20: differential bus, 25 MHz clock); 0 is single ended, 50 MHz. 0x10..0xff and 0x200..0xfff are unmapped module space. Writes to all of them are ignored. Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lasi_ncr710.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/scsi/lasi_ncr710.c b/hw/scsi/lasi_ncr710.c index cbb04017ce9c..c8a28cd987b8 100644 --- a/hw/scsi/lasi_ncr710.c +++ b/hw/scsi/lasi_ncr710.c @@ -45,7 +45,8 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwaddr= addr, return val; } =20 - if (addr >=3D 0x100) { + /* 0x100..0x1ff goes to the chip core. */ + if (addr >=3D 0x100 && addr + size <=3D 0x200) { hwaddr ncr_addr =3D addr - 0x100; if (size =3D=3D 1) { /* @@ -68,6 +69,11 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwadd= r addr, =20 trace_lasi_ncr710_reg_forward_read(addr, val); } else { + /* + * The rest of the module page reads as 0. HP-UX reads a board st= rap + * at 0xd85 (bit 0x20: differential bus, 25 MHz clock); 0 is single + * ended, 50 MHz. + */ val =3D 0; trace_lasi_ncr710_reg_read(addr, val, size); } @@ -83,13 +89,14 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr = addr, =20 /* * 0x00..0x0f is the read only LASI module header (ID/SVERSION/HVERSIO= N); - * writes to it are ignored. + * 0x10..0xff and 0x200..0xfff are unmapped module space. Writes to a= ll + * of them are ignored. */ if (addr <=3D 0x0f) { return; } =20 - if (addr >=3D 0x100) { + if (addr >=3D 0x100 && addr + size <=3D 0x200) { hwaddr ncr_addr =3D addr - 0x100; =20 if (size =3D=3D 1) { @@ -191,7 +198,7 @@ static void lasi_ncr710_realize(DeviceState *dev, Error= **errp) (uint64_t)s->ncr710.scripts_timer); =20 memory_region_init_io(&s->mmio, OBJECT(dev), &lasi_ncr710_mmio_ops, s, - "lasi-ncr710", 0x200); + "lasi-ncr710", 0x1000); sysbus_init_mmio(sbd, &s->mmio); } =20 --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194928; cv=none; d=zohomail.com; s=zohoarc; b=bSZyyGu+k3gu4EBthRbsix1CTWtjF7rR9tL+/T8cWyxBvKWQlnNvHEex9+lvMXlsN52Ke28CHRWh8OgIvveyJLaPLjOXU1SKXD+S5sGEgdgC9UdGx4m3y06hn8nm6D4LgO7xXt+mVGKhvDR5fXIGg+yWwwA8qjo/bCjHE/9s8ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194928; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dbfhzZmvCYz0EfZjp4Apml7ltXRLpLRV+x+jc1oHKVo=; b=FP7Ue02vWSxHZ8TWrgW3hFUiBc73NmOGgKQlpTkERL7u+K3hWmOWAixKs6Nq+6dVRv1LIL+69BBdS5cwyNf8fwCF02yc7pi/XckzZbP+ehhli2QuEoMhxHhUPnSfIu+G0C3cIJ+871Wxz2R4oSH+/YXhagvvtCyy5aZHHIUcPas= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194928208344.5793183020493; Fri, 20 Nov 2026 09:15:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSCn-0005SY-45; Fri, 20 Nov 2026 12:15:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBj-00041W-6U for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:17 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBh-0003wW-IF for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:14 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKEfIG42040039 for ; Fri, 20 Nov 2026 17:14:12 GMT Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2fjtty0p-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:14:12 +0000 (GMT) Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-92137a721c7so16678326d6.1 for ; Fri, 20 Nov 2026 09:14:12 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb88442693sm90564945e9.1.2026.11.20.09.14.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= dbfhzZmvCYz0EfZjp4Apml7ltXRLpLRV+x+jc1oHKVo=; b=mwXOWrm9nmxBXlQH zpDLHuHUxePuqQazR+hGh0g1mHzuC0v7feFFyPqEn9mNjq0rJx2GCSQVh7bIwLjh j4orZMmrUQd7o5MBS+AVXlwMMa/JyfeSU//Z93T2rkiMLDIP6LnToNvsR13CxHcD h79eWu53PXWys5zx245+kk3Xaf41E6Ob0N3CfTSpJWLUsAEPC5S18UbsKxwqMC/S 0s2e/i6d2GHRsgapSt+EtsxPN4TUkVNfAkI077cu5fxMR6HM09J4KfCyIdb4SeDt wzWMUvYH4kd0MhlS/b/zorwf5e18yf86mVJKSVL9g5Qcef9j6aMhXLLFFi1y9+aH N58d/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194852; x=1795799652; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=dbfhzZmvCYz0EfZjp4Apml7ltXRLpLRV+x+jc1oHKVo=; b=ioxjSz6PPjMnfQ9lD7w+vkuBSquV9ior8N5phEBnYy/u6dA5csNEEBz6BS8LKrJyiv 3CLavoo3nVQx/zlVErE8kyEfw9L/0vF6XnK3N8uV13eQHkRSpEM7BDNOhWxsYcTKjzyB idS+LMEfrGPMLudL8gBuBg6Lbj976HjLaz9HGvqG7o45vkTjOeadZO1N21h6b1YAjITW PGr9nu9SjI1BPUgb3VwM3rXCIcYIsCNx6b/eNrH5ZaVxpnmkVWde6iDOfmUv4VRwrzAe C8r/bSbDzktqZTFXd4ZJLFD/GkoiNGdacIbs1Q+Iy+cFPT5TVoyOgTLu91oyf58Hs40K dNmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194852; x=1795799652; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dbfhzZmvCYz0EfZjp4Apml7ltXRLpLRV+x+jc1oHKVo=; b=0hmTy3agjK6PTxysdrkD+rzBuBhJHL8geACNV+YEvhYsi/Z7mfnv1LPy+r8sLaVwhE VrrxEWDDzGruC3zQzmKGC45UExpzde+7RB41g95M69Hf3oJGFaiZBYRSEpg4oye+hXl0 cAj4EsCkgM7NNCwyhdWcL8ouEWygcpPOOyH0PubKmxptXLl8Gx2BeZBtGREg0V/gCpIH HQCKTIDu3JkgW5Bv+QPHHKlh0ZSRdX8uPcrc4L64mJa8/+jrjHkG1r65otyhXcBQaI30 JP5D9NUQ5mrJi0A/utwO4IdifF9jXb5uUM6huDpT9FZR7dOQeigD1UWZg7S9Zir83awI 4/YQ== X-Gm-Message-State: APuU4Z+1q1MNHdiJwqQgTpn60la4tE58iuWhaenxZ+rsmHNx83PA/vkV HB7hsi6OyX9GzYRgsghrDr2ZsGaeG0PqjV0QmNCxVANXQ3JF2OK2y9YM1kUAw0cwZcdzHT7JuPJ MsBoIRzoOnVyEwOLHG4Z5t6r8OU9MtboFfM6ze/HDi7dzqgY4SLGtXezFJ5uanyEZtQ== X-Gm-Gg: AZFdTZfsaP920yOmDr9hpQg4Mzj3ittg7iyk/Rgje3VuTwVLZ1k+eI84TzFHa17qs2D Jc0C/PFx34nQPcLS7oaKN3/r6/sgbBK3dorfbxaNoXVY5MHBA1jdpjQqQDfekaE4Ty2NsI7jLbQ 44Y+3T+7HqDYE/CgrYw+QiDbGZ+MfwVf4dWR+aKiY5eoObnZ9vCzaUdN8moyg5rfJSXIw+kKTfF 6FJ/Cgic+JhYeDOwmDFNQRHYfO9SzFqEjQ+7AJSJ6jpYDt/wRLf8dCizUnX6XkqRSQIdxGkLxiQ VHqtY4iqid6/t85Cv/o2pgVWopX14TK75Oi16sfeAq4O6mdMMWndpomTIw/Fqrzvuhc+OAaKDBM CvtHPrzywAYd3sKy1ocnm5ReFZvBdtgrxDkYB4oLdZr+Jo4fobOrDF5dKpCtCcuDndaCNS4aCwe eVcSp10HMF7fGytg== X-Received: by 2002:a05:620a:4590:b0:93e:6a4b:3ea6 with SMTP id af79cd13be357-949ba965a82mr615578885a.24.1795194851840; Fri, 20 Nov 2026 09:14:11 -0800 (PST) X-Received: by 2002:a05:620a:4590:b0:93e:6a4b:3ea6 with SMTP id af79cd13be357-949ba965a82mr615573185a.24.1795194851345; Fri, 20 Nov 2026 09:14:11 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 13/14] hw/scsi/ncr53c710: Document the SIGP latch deviation Date: Fri, 20 Nov 2026 18:12:33 +0100 Message-ID: <20261120171235.61325-14-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: NdAYv1kgj8KpJR0b7ibcLCbK_kjsNHaW X-Proofpoint-GUID: NdAYv1kgj8KpJR0b7ibcLCbK_kjsNHaW X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX6DEaROHFlYNB TmYn6jdgtRoo3RGBK0aRxwPyjveuZPc7a1jf8+3Wc3uFIx6hisNp16KmXik9Eqk677b1WoeQs4g 48OCurmlNWRG4zylWLbbtdztx1Tn8X1oWmcHk4QQerqlBTRkpYQvTwgT0peuF6wQHGcyYzPeyk9 G6htTA7NBoBxO5P+Q7p2lZuCvxV/3HR30Yp2UKePIH6ZaToDauOBcrXI3xgjsJ3BO732NH04vro 4DYXrqQECadATKtUOrgeDpvSmS7sMZtWwB8+hJgV5hZmffClemxI8M2xuj5TaoMzDyOCuBEsctl Uvq+AyPm3RPdJOPMywcF+1YTrvtUr6+VoAkmoh1Hb+jO2widfWQEoApVm5Xo70ua4BCOb0eYfFo jd7/i0vrsy1SGtekzoBD3LYB64aZjfSipc8PQoVXlSxF/mZxx4WDDHV3pC+7wCkFT+29zl2JnyK ONYGWIoikLlQN4aGddw== X-Authority-Analysis: v=2.4 cv=XcccX455 c=1 sm=1 tr=0 ts=6b007fe4 cx=c_pps a=UgVkIMxJMSkC9lv97toC5g==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=GChFR1gXfXaX4RAfPo0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=1HOtulTD9v-eNWfpl4qZ:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXx5HveQOFL2sN JsTWi7F8hVYf+LP+iDxnh6+H5XRvYgTsh4rN2FOakIrzfDTFqJy3mQU69zMlka6XYa8TgF+ntCd JvqDJgNQ8kRK54DDTMtNNBiEcMZ0eOY= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194928953158500 Comment only, no functional change. The data manual describes SIGP (ISTAT bit 5) as a read/write flag that stays set until reset by the CPU, either through ISTAT or by reading CTEST2. The emulation drops the bit at once when it is set while the engine is halted and remembers the kick in sigp_pending_resume instead. Note the deviation at the code. The reason is not documented in the history. AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/ncr53c710.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index f75540da7720..af26d26a05bb 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -1524,6 +1524,14 @@ static void lsi_reg_writeb(NCR710State *s, int offse= t, uint8_t val) * Reselect consumption would, without disturbing the pending * completion. Remember the kick so the next command is selec= ted * once the engine parks again at Wait Reselect. + * + * This deviates from the data manual, which describes SIGP as= a + * read/write flag that stays set until the CPU resets it, eit= her + * via ISTAT or by reading CTEST2: here a halted engine drops = the + * bit at once, so a read of ISTAT or CTEST2 no longer sees it. + * The reason is not documented beyond the commit that added + * sigp_pending_resume (6bf09c62fa), which only says that a ki= ck + * on a stopped engine is held and replayed once the engine pa= rks. */ s->istat &=3D ~LSI_ISTAT0_SIGP; s->sigp_pending_resume =3D true; --=20 2.55.0 From nobody Mon Nov 23 04:26:16 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=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795194923; cv=none; d=zohomail.com; s=zohoarc; b=GL3JqErwaG120arP2sOv9zQKvplsiauNerMAVMWHZzpPNDc8ghXjpLMDb+NnA1FAbMS8F8rkzp+TKOvCjerpVw8Tyq8UYed01wuTt75s982a54dOlcVDzMYnJaKSizixs4t8PmR9LynvMv64C2kwPkbMnmdOqhdT94BzMFIWV9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795194923; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=USH/JKygShHw6X3ZYFQaznWFbfNOQiqRfMa4UtUGKOU=; b=MSndEy3W2yyufYJ+sJ00HcqgTlS8s9wbtrvjzScRQesJAh11AqQdLV+2L6f+UNU3y/QVI1w0HkFohyijyww0hz7teac741PTbD1Pzo3G5w0tALYIsAf+McrqUzAP8yx/RfsxRgqOrnHJY7oRZxDDiNVK74dszwIsEr4UDlP11U8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795194923092771.4545636319194; Fri, 20 Nov 2026 09:15:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xUSC7-0004Pt-BS; Fri, 20 Nov 2026 12:14:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBq-00046v-By for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:25 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xUSBo-0003xb-PJ for qemu-devel@nongnu.org; Fri, 20 Nov 2026 12:14:22 -0500 Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AKGFsvH3830173 for ; Fri, 20 Nov 2026 17:14:19 GMT Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j2sjwg7ns-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 20 Nov 2026 17:14:19 +0000 (GMT) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-93f3969a2a7so182061185a.2 for ; Fri, 20 Nov 2026 09:14:19 -0800 (PST) Received: from localhost.localdomain (pmd666.hd.free.fr. [82.67.153.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf685asm6190814f8f.20.2026.11.20.09.14.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Nov 2026 09:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= USH/JKygShHw6X3ZYFQaznWFbfNOQiqRfMa4UtUGKOU=; b=jqP+gq664YQJTjO9 RsW1aliazSXrslJ1K/p63BcfxxnkQbZ/HODDfm6bDWqkQgewCrJ6XnYGO5ScDMum uC6DS5zl9sz5y6fwOF/jDtiqKJ6fBRcDXWaXooukyQ1bBwvf5vtyrhaff+1shxV4 vbX9YNg2g7zSOoBKRVO3VDtD2G8kBSJgAnyi0smSe37hEhFwnUN1Po1LutvLqyxB vt1Ur8ZUZNmyj4JGY/s7DNuvFWobOLoY1VuaC0HZmPp03Qsre+8MSsuybWbV9me2 HEpJWOiweGk9EawU70gtzxUHuIVbVIxb792wsjCpz1DAAfg1VOrK6413h3yHSXM6 J/p19Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795194859; x=1795799659; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=USH/JKygShHw6X3ZYFQaznWFbfNOQiqRfMa4UtUGKOU=; b=WuY/8dAjcfIeLT4hisIwiZy/b9LsYuIGov6CCLbJJ+8LyXEBgQPn0QTkMJC+NyxGgq dA7ATJ/XjopmtINTAVIVdc9kelxfvqe9YJasukZYenIxRvakxRf+PDkkvE3nIhLZwJqA So5/Hdp1Tjw9DwnC8a1/ZLqPYOLLWWxABX5tr2Xs0bcnzMk/iBP65DGA1O48yBusrOOT ncLpknyDhtIwCgmaOspqQSHJjo1n7+vUBLq2Q5l7/AafZ+Ahj5QfXAy7miFV3XUvZh8B 9GhKj/KfHVM2g66W4Ij1ZyJrmJGIOvLYd0TfYHLWkMA7or0bPV4xP4bDZdQSNqZz2SZl E22g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194859; x=1795799659; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=USH/JKygShHw6X3ZYFQaznWFbfNOQiqRfMa4UtUGKOU=; b=HFgRQii5vxj4JbLuT3+rIuOtKcjWFdSxSqNBfUk1rNHluU+bpO3GbnBZxFmfFvtH+B Zf8TYLP5Unch3DfZZSL+JaLZlTvV3aCjrz1Sqoh++dANXHQXz2dkH5ItC549iPRoLyjE 9VFP71begHCxfkznRErCeEsiE14OrnpLOlVbVOFJyNUmcF9p9DwEQ1KeJphmpcoL78l8 2TiK2W41/ilX2R5rEvhzgaSSHUBjdv2OqsF2p6i30IdPWbTAE+wbvasdcKRmNBMzKkkZ RK/uAtjSeNArqa2JfJK8T7wTpZaUFdD7dG5njUMWypqhmMmYUs/wqeTATCVZ/01nns1W 2f0A== X-Gm-Message-State: APuU4Z+UHPGL/061cOAv7xDY3nzZcOI5Mz/Kq8GnfKgcbJg8Ewa9Izea /A/+vzpkKHwh7eoz2DnYonXXrkAUhBoD9qdq6Uh6KyIdilCPWLH8obIHEni2/zLQgedqid5EY0x 1eI9W0ypCTtnZb0TU/V/a8zxTVc+QM1gyY2hi+1xIkiAwvEU4Ww0hsTdKEXevPx9b4A== X-Gm-Gg: AYBFou01CcMAiwCxRpanRU5RsxeqvTLQNCuKowL7oXQB3gXS0xutIIVVvc6TNzQqqbf o5+9Zqc4xfX9YoDxJwCvAXwMd94R5JuVms1kdTDZja/lHE5KKth+ZMnsKMNs+RvfVy5ee2GQsv9 MJ0BW1VoZQ9zcDTmCvTjpycROZP61dLk3zqCd5tFvX0+mnCqS5GvWBotgpjCU3Zeknly44b8CR1 +90wCKHpRY0rUPiRrNDLbf4xEqV+aXNSVeNadaod1LMjIuNNA/sdqIdv3pXImaGPA3RQJCVreFn xrLEINdm/xlp1wuqFN9FS9q1qAtpNxxyaEVrTOASc5/YOLSkLVrjNwbNzVUtZmXVI3mRspteEBI zH1M9dyKLQe3KRBqmgroCSUuhgG1X2q0+vg0g7UBYnCXwBGZfc95z/vizBXjT30qvTizbDZiPlB Jy6gzJPJL5C29mLQ== X-Received: by 2002:a05:620a:4443:b0:949:6193:acc5 with SMTP id af79cd13be357-949bac79da8mr619368785a.74.1795194859015; Fri, 20 Nov 2026 09:14:19 -0800 (PST) X-Received: by 2002:a05:620a:4443:b0:949:6193:acc5 with SMTP id af79cd13be357-949bac79da8mr619364085a.74.1795194858438; Fri, 20 Nov 2026 09:14:18 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Helge Deller , Richard Henderson , Paolo Bonzini , Mark Cave-Ayland , Fam Zheng , Keith Monahan , BALATON Zoltan , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-11.2? v4 14/14] hw/scsi/ncr53c710: Bump the migration version Date: Fri, 20 Nov 2026 18:12:34 +0100 Message-ID: <20261120171235.61325-15-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com> References: <20261120171235.61325-1-philmd@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: uuNhgpYaQsupsfof57p5n1lKhnk9zJ1- X-Proofpoint-GUID: uuNhgpYaQsupsfof57p5n1lKhnk9zJ1- X-Authority-Analysis: v=2.4 cv=dZ4VTnXe c=1 sm=1 tr=0 ts=6b007feb cx=c_pps a=HLyN3IcIa5EE8TELMZ618Q==:117 a=nz36NW0qrpeEijYxj/H2Ew==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=zCys0jnkAAAA:8 a=EUspDBNiAAAA:8 a=10KMK3kvz0OphFO8KX0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=bTQJ7kPSJx9SKPbeHEYW:22 a=AAPjE2N9MkmuCaafd2wf:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfX1wlEitxpvBVQ Ff3hnMQ0kc9rG1HQ5XwiE3+ArKYd8qECPg07ExnW9W9XOdM6cjQhPQByGvoUPYjEmjcvpNEKMF2 wz8/PjJtZpwuuASvVqAkJW+h0ZzF6tM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIwMDA2OCBTYWx0ZWRfXwTgier3DT3TN SF2s8iMWixOqS08xCRoJG1OWPBDWZjT7Ocw4hbIxsd1dizrT8RgumK899w0tP9cYtecVWpC1sY5 stNUrR30oVGZ2a7Y/kIOeM9qXblQKfMT2blDm5pY059EXPNUiPFLmbNMwrSKpgTIZJi8P2KGcQT A073I6QowZOe9Y0E/L6gq9/aswRoRwFgoUCdNs4GAJjS8xFUhISI4Hqt2nL1keXCJTECBrDaK5s kMmxu+vu+KgFsZE2xMGWC+q7JN2P4E35XJ9kvo0Dojsfjcr8unwbfrTm0ATQYEskjD7RPjjSn76 3VBGUZfBzVRRBIpsFQy65QzWA1CurGEVd3BgoWZ4H13KsTPVTj2H/vkrZkH9zZY+SGv7uN+qkXz 8sAzbghmJ2EEtj88Jfpk+OZB3MnT6d6F5qJ2EFzH2o7EFo5cgQw1CY6tNr9cngXxC14Yc1s+8jp D/DRtAHkYvRmECUKpDw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-20_05,2026-11-19_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 spamscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611200068 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1795194924905158500 From: Keith Monahan The migration format is incompatible with the model this replaces, so the ncr710 and lasi_ncr710 vmstate descriptions raise minimum_version_id in lockstep: an old stream is rejected rather than silently misparsed. sigp_pending_resume is a version 3 field: a deferred SIGP kick can be live across a migration point. Intermediate patches of this series do not preserve migration streams. Signed-off-by: Keith Monahan Signed-off-by: Helge Deller AI-used-for: Patch series decomposition (commit splitting and ordering) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lasi_ncr710.c | 4 ++-- hw/scsi/ncr53c710.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/scsi/lasi_ncr710.c b/hw/scsi/lasi_ncr710.c index c8a28cd987b8..62608d039c1e 100644 --- a/hw/scsi/lasi_ncr710.c +++ b/hw/scsi/lasi_ncr710.c @@ -163,8 +163,8 @@ static const MemoryRegionOps lasi_ncr710_mmio_ops =3D { =20 static const VMStateDescription vmstate_lasi_ncr710 =3D { .name =3D "lasi-ncr710", - .version_id =3D 1, - .minimum_version_id =3D 1, + .version_id =3D 2, + .minimum_version_id =3D 2, .fields =3D (const VMStateField[]) { VMSTATE_STRUCT(ncr710, LasiNCR710State, 1, vmstate_ncr710, NCR710S= tate), VMSTATE_END_OF_LIST() diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c index af26d26a05bb..4a37d011f229 100644 --- a/hw/scsi/ncr53c710.c +++ b/hw/scsi/ncr53c710.c @@ -1674,8 +1674,9 @@ static int lsi_post_load(void *opaque, int version_id) =20 const VMStateDescription vmstate_ncr710 =3D { .name =3D "ncr710", - .version_id =3D 1, - .minimum_version_id =3D 1, + /* minimum_version_id rejects streams from the earlier 53C710 model. */ + .version_id =3D 3, + .minimum_version_id =3D 2, .pre_save =3D lsi_pre_save, .post_load =3D lsi_post_load, .fields =3D (const VMStateField[]) { @@ -1689,7 +1690,11 @@ const VMStateDescription vmstate_ncr710 =3D { VMSTATE_UINT32(select_tag, NCR710State), VMSTATE_INT32(command_complete, NCR710State), VMSTATE_BOOL(script_running, NCR710State), - VMSTATE_BOOL(sigp_pending_resume, NCR710State), + /* + * Version 3+. A deferred SIGP kick can be live across a migration + * point. + */ + VMSTATE_BOOL_V(sigp_pending_resume, NCR710State, 3), =20 VMSTATE_UINT8(scntl0, NCR710State), VMSTATE_UINT8(scntl1, NCR710State), --=20 2.55.0