hw/scsi/ncr53c710: rewrite to support HP-UX, Linux and NetBSD
cover hw/scsi/ncr53c710: rewrite to support HP-UX, Linux and NetBSD
This series replaces the NCR 53C710 model so HP-UX 10.20 (including the Ignite/16700A install media) installs and boots on the HP 715 (-M 715), while keeping the in tree Linux lasi700 and NetBSD osiop drivers working.
I first tried to fix the existing model. It took about a dozen fixes just to get the kernel's own 53c710 driver to negotiate its first command, and even then HP-UX would not boot reliably. Two of the faults are in the core interpreter itself. The model is connected only: no target initiated disconnect/reselect, which HP-UX needs (and so does any tagged, overlapped I/O). And it runs SCRIPTS synchronously inside the guest register write, so completion interrupts come back reentrantly instead of the way the real chip delivers them. Fixing either one meant rewriting the interpreter, so I rewrote it.
The new model is derived from lsi53c895a.c, the maintained sibling in the same NCR/LSI SCRIPTS family. Its disconnect/reselect, asynchronous completion and DMA paths already work across many guests. I adapted it to the 710: big endian SCRIPTS and table indirect fetch, 24 bit DMA byte counts, the 710 register map, and the single byte interrupt model. The two LSI models share structure now, so a fix to one can carry to the other.
Patch 1 is an independent LASI interrupt controller fix (a latched request register that floods the installed HP-UX boot with "unexpected core I/O interrupt"). Patch 2 is the rewrite, which depends on it.
Tested: HP-UX 10.20 install + reboot (Ignite 16700A and an overlapping tagged software install); Debian install + boot (Linux 53c700); NetBSD/hppa 9.4 and 10.1 boot + device enumeration (osiop).
Keith Monahan (2):
hw/misc/lasi: derive IRR from pending and unmasked sources hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
hw/misc/lasi.c | 27 +- hw/scsi/lasi_ncr710.c | 120 +- hw/scsi/lasi_ncr710.h | 28 +- hw/scsi/ncr53c710.c | 3062 +++++++++++++++++------------------------ hw/scsi/ncr53c710.h | 295 ++-- hw/scsi/trace-events | 31 +- 6 files changed, 1500 insertions(+), 2063 deletions(-)
base-commit: 30e8a06b64aa58a3990ba39cb5d09531e7d265e0
Signature · 1 line
2.43.0
PATCH 1/2 hw/misc/lasi: derive IRR from pending and unmasked sources
The LASI interrupt controller request register (IRR) was latched: a bit was set when a source asserted and then neither cleared nor re-evaluated against the mask, so a request the guest masked, or that a level source dropped, stayed set forever. The parisc core I/O dispatcher reads IRR (not IPR) to find its source and relies on a request clearing once the device deasserts or is masked, so a stuck bit is redelivered on every later interrupt as an "unexpected core I/O interrupt".
On an installed HP-UX 10.20 system the i82596 LAN raises an interrupt no loaded driver acknowledges; the held request latched into IRR, masking it had no effect, and the flood wedged the boot before it reached multiuser.
Derive IRR as (pending and unmasked) and track the level of each source in IPR (cleared when it deasserts), matching the hardware and the in tree parisc gsc/lasi driver.
--- hw/misc/lasi.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
hw/misc/lasi.c +21 -6
@@ -62,7 +62,17 @@ static MemTxResult lasi_chip_read_with_attrs(void *opaque, hwaddr addr,switch (addr) {case LASI_IRR : - val = s->irr; +/* +* The interrupt request register reports the interrupts that are both +* pending and unmasked. It is derived live from IPR and IMR rather +* than latched: masking a source must remove it from IRR immediately, +* and a source that is masked or no longer asserted must stop being +* reported. The parisc core I/O interrupt dispatcher reads IRR and +* relies on a request clearing once the device deasserts or is masked; +* a latched bit that never cleared would be redelivered forever as a +* phantom "unexpected" interrupt. +*/ + val = s->ipr & s->imr;break ;case LASI_IMR : val = s->imr;
@@ -234,13 +244,18 @@ static void lasi_set_irq(void *opaque, int irq, int level)if (level) { s->ipr |= bit; -if (bit & s->imr) { +if ((bit & s->imr) && (s->icr &ICR_BUS_ERROR_BIT ) ==0 ) {uint32_t iar = s->iar; - s->irr |= bit; -if ((s->icr &ICR_BUS_ERROR_BIT ) ==0 ) { -stl_be_phys (&address_space_memory, iar &-32 , iar &31 ); - } +stl_be_phys (&address_space_memory, iar &-32 , iar &31 ); } + }else { +/* +* The interrupt sources are level triggered, so a source that drops +* its request must clear its pending bit. Otherwise the bit stays set +* in IPR (and hence IRR) and is redelivered as a phantom "unexpected" +* core I/O interrupt on every later interrupt. +*/ + s->ipr &= ~bit; } }
Signature · 1 line
2.43.0
PATCH 2/2 hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
In reply to Keith MonahanRewrite 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).
Tested through real SCSI I/O on the HP 715 (-M 715, LASI):
- HP-UX 10.20 installs and reboots into the installed system, on both the Ignite (16700A) media and a software install that overlaps tagged commands.
- Linux lasi700/53c700 installs and boots Debian off the 710.
- NetBSD/hppa 9.4 and 10.1 (osiop) boot and enumerate disk and CD-ROM.
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.
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. The interpreter also guards the reentrancy class behind CVE-2023-0330. Untagged and polled transfers keep inline completion.
The c720 driver further 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), and a SIGP kick that lands on a stopped engine is held and replayed once it parks.
This patch depends on the preceding LASI interrupt controller fix ("hw/misc/lasi: derive IRR from pending and unmasked sources"), without which an unacknowledged i82596 LAN interrupt floods the installed HP-UX boot with "unexpected core I/O interrupt".
SDTR/WDTR/PPR negotiation is declined with MESSAGE REJECT. The HP-UX 10.20 install kernel is nonconformant: its self modifying SCRIPTS reads a second message byte after the reject 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.
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.
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.
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).
---
Notes:
checkpatch note: this trips 14 "trailing statements should be on next line" errors, all on the one-line "case addr: ...; break;" register decode macros. I kept that form because it's lifted straight from the parent lsi53c895a.c, which hits checkpatch on the same idiom the same 14 times. Happy to spell them out if you'd rather.
hw/scsi/lasi_ncr710.c | 120 +- hw/scsi/lasi_ncr710.h | 28 +- hw/scsi/ncr53c710.c | 3062 +++++++++++++++++------------------------ hw/scsi/ncr53c710.h | 295 ++-- hw/scsi/trace-events | 31 +- 5 files changed, 1479 insertions(+), 2057 deletions(-)
hw/scsi/lasi_ncr710.c +50 -70
@@ -1,12 +1,12 @@/* -* LASI Wrapper for NCR710 SCSI Controller +* LASI wrapper for the NCR 53C710 SCSI controller * * Copyright (c) 2025 Soumyajyotii Ssarkar <[email protected]> -* This driver was developed during the Google Summer of Code 2025 program. -* Mentored by Helge Deller <[email protected]> +* Developed during Google Summer of Code 2025, mentored by +* Helge Deller <[email protected]>. * -* NCR710 SCSI Controller implementation -* Based on the NCR53C710 Technical Manual Version 3.2, December 2000 +* LASI module glue around the 53C710 core in ncr53c710.c: it embeds one +* NCR710State by value and maps it onto the HP 715 (-M 715) LASI bus. * * SPDX-License-Identifier: GPL-2.0-or-later */
@@ -24,7 +24,6 @@#include "system/dma.h" #define LASI_710_SVERSION 0x00082 -#define SCNR 0xBEEFBABE#define LASI_710_HVERSION 0x3D#define HPHW_FIO 5/* Fixed I/O module */
@@ -34,8 +33,6 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwaddr addr,LasiNCR710State *s =LASI_NCR710 (opaque);uint64_t val =0 ; -trace_lasi_ncr710_reg_read (addr,0 , size); -if (addr ==0x00 ) {/* Device ID */ val = (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, hwaddr addr,if (addr >=0x100 ) {hwaddr ncr_addr = addr -0x100 ;if (size ==1 ) { +/* +* Single byte access: flip the byte lane (PA-RISC big endian +* access -> the chip's little endian register order). +*/ ncr_addr ^=3 ; -NCR710_DPRINTF ("Reading value to LASI WRAPPER == 0x%lx%s, " -"val=0x%lx, size=%u\n" , - addr -0x100 , size ==1 ?" (XORed)" :"" , - val, size); val =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 =0 ;for (unsigned i =0 ; i < size; i++) {uint8_t byte_val =ncr710_reg_read (&s->ncr710, ncr_addr + i,1 ); val |= ((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); }trace_lasi_ncr710_reg_forward_read (addr, val);
@@ -84,7 +81,13 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr addr,trace_lasi_ncr710_reg_write (addr, val, size); -if (addr <=0x0F ) { +/* +* 0x00..0x0f is the read only LASI module header (ID/SVERSION/HVERSION) and +* 0x10..0xff is unmapped module space; writes to both are ignored. The +* SCSI bus reset is driven through the chip's SCNTL1.RST at forwarded +* offset 0x101 (see ncr53c710.c), not through this window. +*/ +if (addr <=0x0f ) {return ; }
@@ -93,16 +96,10 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr addr,if (size ==1 ) { ncr_addr ^=3 ; -NCR710_DPRINTF ("Writing value to LASI WRAPPER == 0x%lx%s, " -"val=0x%lx, size=%u\n" , - addr -0x100 , size ==1 ?" (XORed)" :"" , - val, size);ncr710_reg_write (&s->ncr710, ncr_addr, val, size); }else {for (unsigned i =0 ; i < size; i++) {uint8_t byte_val = (val >> (i *8 )) &0xff ; -NCR710_DPRINTF (" Writing byte %u to NCR addr 0x%lx: 0x%02x\n" , - i, ncr_addr + i, byte_val);ncr710_reg_write (&s->ncr710, ncr_addr + i, byte_val,1 ); } }
@@ -113,10 +110,7 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr addr, } } -/* -* 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 +123,30 @@ static void lasi_ncr710_command_complete(SCSIRequest *req, size_t resid)ncr710_command_complete (req, resid); } -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); } +static void lasi_ncr710_free_request (SCSIBus *bus,void *priv) +{ +g_free (priv); +} +static const struct SCSIBusInfo lasi_ncr710_scsi_info = { .tcq = true, - .max_target =8 , - .max_lun =8 ,/* full LUN support */ +/* +* Narrow (8 bit) SCSI bus: IDs 0 to 7 and a 3 bit IDENTIFY LUN field, i.e. +* LUNs 0 to 7. SCSI bus.c treats max_target/max_lun as inclusive maxima. +*/ + .max_target =7 , + .max_lun =7 , .transfer_data = lasi_ncr710_transfer_data, .complete = lasi_ncr710_command_complete, .cancel = lasi_ncr710_request_cancelled, + .free_request = lasi_ncr710_free_request, };static const MemoryRegionOps lasi_ncr710_mmio_ops = {
@@ -157,12 +161,9 @@ static const MemoryRegionOps lasi_ncr710_mmio_ops = {static const VMStateDescription vmstate_lasi_ncr710 = { .name ="lasi-ncr710" , - .version_id =1 , - .minimum_version_id =1 , + .version_id =2 , + .minimum_version_id =2 , .fields = (const VMStateField []) { -VMSTATE_UINT32 (hw_type, LasiNCR710State), -VMSTATE_UINT32 (sversion, LasiNCR710State), -VMSTATE_UINT32 (hversion, LasiNCR710State),VMSTATE_STRUCT (ncr710, LasiNCR710State,1 , vmstate_ncr710, NCR710State),VMSTATE_END_OF_LIST () }
@@ -179,16 +180,17 @@ static void lasi_ncr710_realize(DeviceState *dev, Error **errp) &lasi_ncr710_scsi_info); s->ncr710.as = &address_space_memory; s->ncr710.irq = s->lasi_irq; +QTAILQ_INIT (&s->ncr710.queue); - s->ncr710.reselection_retry_timer = + s->ncr710.scripts_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , - ncr710_reselection_retry_callback, + ncr710_scripts_timer_callback, &s->ncr710);ncr710_soft_reset (&s->ncr710);trace_lasi_ncr710_timers_initialized ( - (uint64_t )s->ncr710.reselection_retry_timer); + (uint64_t )s->ncr710.scripts_timer);/* Initialize memory region */ memory_region_init_io(&s->mmio, OBJECT(dev), &lasi_ncr710_mmio_ops, s,
@@ -196,32 +198,19 @@ static void lasi_ncr710_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->mmio); } -void lasi_ncr710_handle_legacy_cmdline (DeviceState *lasi_dev) +static void lasi_ncr710_unrealize (DeviceState *dev) { -LasiNCR710State *s =LASI_NCR710 (lasi_dev); -SCSIBus *bus = &s->ncr710.bus; -int found_drives =0 ; - -if (!bus) { -return ; - } +LasiNCR710State *s =LASI_NCR710 (dev); -for (int unit =0 ; unit <=7 ; unit++) { -DriveInfo *dinfo =drive_get (IF_SCSI , bus->busnr, unit); -if (dinfo) { -trace_lasi_ncr710_legacy_drive_found (bus->busnr, unit); - found_drives++; - } - } +timer_free (s->ncr710.scripts_timer); + s->ncr710.scripts_timer =NULL ; +} -trace_lasi_ncr710_handle_legacy_cmdline (bus->busnr, found_drives); +void lasi_ncr710_handle_legacy_cmdline (DeviceState *lasi_dev) +{ +LasiNCR710State *s =LASI_NCR710 (lasi_dev); -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); } DeviceState *lasi_ncr710_init(MemoryRegion *addr_space, hwaddr hpa,
@@ -248,20 +237,12 @@ static void lasi_ncr710_reset(DeviceState *dev)ncr710_soft_reset (&s->ncr710); } -static void lasi_ncr710_instance_init (Object *obj) -{ -LasiNCR710State *s =LASI_NCR710 (obj); - - s->hw_type =HPHW_FIO ; - s->sversion =LASI_710_SVERSION ; - s->hversion =LASI_710_HVERSION ; -} -static void lasi_ncr710_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->realize = lasi_ncr710_realize; + dc->unrealize = lasi_ncr710_unrealize;set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); dc->fw_name ="scsi" ; dc->desc ="HP-PARISC LASI NCR710 SCSI adapter" ;
@@ -274,7 +255,6 @@ static const TypeInfo lasi_ncr710_info = { .name = TYPE_LASI_NCR710, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(LasiNCR710State), - .instance_init = lasi_ncr710_instance_init, .class_init = lasi_ncr710_class_init, };
hw/scsi/lasi_ncr710.h +3 -25
@@ -1,12 +1,9 @@/* -* LASI Wrapper for NCR710 SCSI Controller +* LASI wrapper for the NCR 53C710 SCSI controller * * Copyright (c) 2025 Soumyajyotii Ssarkar <[email protected]> -* This driver was developed during the Google Summer of Code 2025 program. -* Mentored by Helge Deller <[email protected]> -* -* 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 <[email protected]>. * * 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) -#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 ;
hw/scsi/ncr53c710.c +1284 -1778
2,717 lines not on this page · raw message
hw/scsi/ncr53c710.h +116 -179
295 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH 2/2] hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
Quoted 10 lines · 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).
Quoted 6 lines
hw/scsi/lasi_ncr710.c | 120 +- hw/scsi/lasi_ncr710.h | 28 +- hw/scsi/ncr53c710.c | 3062 +++++++++++++++++------------------------ hw/scsi/ncr53c710.h | 295 ++-- hw/scsi/trace-events | 31 +- 5 files changed, 1479 insertions(+), 2057 deletions(-)
This is way too much change to be reviewable as a single patch, I'm afraid. Can you break it down into meaningful pieces, please?
thanks
-- PMM
Re: [PATCH 2/2] hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
Quoted 3 lines · Peter Maydell
This is way too much change to be reviewable as a single patch, I'm afraid. Can you break it down into meaningful pieces, please?
Thanks for taking a look at this. I'm brand new to this process, so please bear with me, as my questions come from not understanding more than any type of disagreement.
My thoughts are to break it down like this: keep the lasi.c IRR fix patch 1 by itself as is, and then further decompose patch 2 into:
* Glue cleanup (lasi_ncr710.c/h): remove dead scaffolding.
* Base engine rewrite + trace-events
* HP-UX overlapped tag support
* ATN-state HP-UX/Netbsd handling
This should help reduce the overall cognitive load in the review process.
However, this still leaves the new 2k lines code in ncr53c710.c, the base engine. Because this is a complete rewrite from scratch (using existing lsi53c895.c as the base), you can't/shouldn't really diff the original to mine. I tried it, fwiw, and the results aren't pretty.
Any further decomposition of the engine you'd end up with non-building intermediate states that don't really work by themselves.
Another point is that I haven't done extensive mid-point testing to know what deploying half the solution might do. For instance, you MIGHT be able to get Linux and NetBSD to boot and/or install without the HP-UX support and disambiguation patches, but I'm not sure.
Does my breakdown make sense?
Thanks,
Keith M
Re: [PATCH 2/2] hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
Quoted 10 lines · Keith Monahan
Quoted 3 lines · Peter Maydell
This is way too much change to be reviewable as a single patch, I'm afraid. Can you break it down into meaningful pieces, please?
Thanks for taking a look at this. I'm brand new to this process, so please bear with me, as my questions come from not understanding more than any type of disagreement.
My thoughts are to break it down like this: keep the
lasi.cIRR fix patch 1 by itself as is, and then further decompose patch 2 into:
Quoted 8 lines
* Glue cleanup (lasi_ncr710.c/h): remove dead scaffolding.
* Base engine rewrite + trace-events
* HP-UX overlapped tag support
* ATN-state HP-UX/Netbsd handlingThis should help reduce the overall cognitive load in the review process.
However, this still leaves the new 2k lines code in
ncr53c710.c, the base engine. Because this is a complete rewrite from scratch (using existinglsi53c895.cas the base), you can't/shouldn't really diff the original to mine. I tried it, fwiw, and the results aren't pretty.
Would it be possible to reorganise the existing lsi53c895.c to split the engine you want to reuse in a separate object or module or file so it can be shared without duplicating it? Then the changes to ncr53c710.c should be less as it would just use the parts that were split off and not copy and modify them. If that's possible it would also be better as the shared parts would not be duplicated so both device models could benefit from it but I understand that needs knowledge about 53c859 and testing that too so it's more work but may be the preferred way to go.
Regards,
BALATON Zoltan
Quoted 11 lines
Any further decomposition of the engine you'd end up with non-building intermediate states that don't really work by themselves.
Another point is that I haven't done extensive mid-point testing to know what deploying half the solution might do. For instance, you MIGHT be able to get Linux and NetBSD to boot and/or install without the HP-UX support and disambiguation patches, but I'm not sure.
Does my breakdown make sense?
Thanks,
Keith M
Re: [PATCH 2/2] hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
Quoted 1 line · BALATON Zoltan
Would it be possible to reorganise the existing
lsi53c895.cto split the engine you want to reuse in a separate object or module or file so it can be shared without duplicating it? Then the changes toncr53c710.cshould be less as it would just use the parts that were split off and not copy and modify them. If that's possible it would also be better as the shared parts would not be duplicated so both device models could benefit from it but I understand that needs knowledge about 53c859 and testing that too so it's more work but may be the preferred way to go.
Yes, definitely agree with you generally in terms of good architectural design. However, I think in practical terms, there's less overlap than you think.
There are two major issues, and two minor:
* The interrupt model differs: 710 is single-byte, 895A is stack model with two registers. Major.
* Reselection: Considerably different between 53C700 and 8xx family. Major.
* Endianness: big (710) vs little (895)
* Register map.
I did a quick per-function analysis this morning, just to make sure I didn't end up somewhere different from where I started.
* About 14% of the code is either verbatim or only had slight modification.
* With about 75% of it being either completely rewritten, or 710-only specific code.
So the shared design lineage is real. A fix in one can inform the other, but the code itself largely is not shared.
The blast radius of modifying lsi53c895a seems huge to me. I think this would affect a fair number of other guests well beyond what would be supported on LASI. The risk/reward ratio just wouldn't hold, and you are absolutely right about the testing asymmetry. Re-validating all of those guests seems like a nightmare.
There's another point here too: hppa is a smaller community of users, and while I'm confident that what I'm presenting is solid, I really don't want to expand the scope of the potential impact. With me being new, I don't think this is a prudent approach.
Thanks,
Keith
Quoted 34 lines · Keith Monahan
This series replaces the NCR 53C710 model so HP-UX 10.20 (including the Ignite/16700A install media) installs and boots on the HP 715 (-M 715), while keeping the in tree Linux lasi700 and NetBSD osiop drivers working.
I first tried to fix the existing model. It took about a dozen fixes just to get the kernel's own 53c710 driver to negotiate its first command, and even then HP-UX would not boot reliably. Two of the faults are in the core interpreter itself. The model is connected only: no target initiated disconnect/reselect, which HP-UX needs (and so does any tagged, overlapped I/O). And it runs SCRIPTS synchronously inside the guest register write, so completion interrupts come back reentrantly instead of the way the real chip delivers them. Fixing either one meant rewriting the interpreter, so I rewrote it.
The new model is derived from
lsi53c895a.c, the maintained sibling in the same NCR/LSI SCRIPTS family. Its disconnect/reselect, asynchronous completion and DMA paths already work across many guests. I adapted it to the 710: big endian SCRIPTS and table indirect fetch, 24 bit DMA byte counts, the 710 register map, and the single byte interrupt model. The two LSI models share structure now, so a fix to one can carry to the other.Patch 1 is an independent LASI interrupt controller fix (a latched request register that floods the installed HP-UX boot with "unexpected core I/O interrupt"). Patch 2 is the rewrite, which depends on it.
Tested: HP-UX 10.20 install + reboot (Ignite 16700A and an overlapping tagged software install); Debian install + boot (Linux 53c700); NetBSD/hppa 9.4 and 10.1 boot + device enumeration (osiop).
Keith Monahan (2):
hw/misc/lasi: derive IRR from pending and unmasked sources hw/scsi/ncr53c710: rewrite the 53C710 SCRIPTS engine
Quoted 7 lines
hw/misc/lasi.c | 27 +- hw/scsi/lasi_ncr710.c | 120 +- hw/scsi/lasi_ncr710.h | 28 +- hw/scsi/ncr53c710.c | 3062 +++++++++++++++++------------------------ hw/scsi/ncr53c710.h | 295 ++-- hw/scsi/trace-events | 31 +- 6 files changed, 1500 insertions(+), 2063 deletions(-)
Thanks for this series!!!
I've tested this driver with HP-UX 10.20 (which didn't worked with the previous ncr710 driver yet), and it's a big step forward.
Thanks for doing this.
Quoted 4 lines · Helge Deller
Thanks for this series!!!
I've tested this driver with HP-UX 10.20 (which didn't worked with the previous ncr710 driver yet), and it's a big step forward.
Thanks for doing this.
You're welcome! Thanks for working with me on this! This LASI NCR710 support for HP-UX is a feature I've wanted for years, so I'm glad to had the time to bring it life!
Keith