On 13/06/2019 21:01, BALATON Zoltan wrote:
The problem here is that the fallback works by "executing" an in-built copy of the FCode if a valid ROM can't be located during the SBus probe. But with -vga none this causes issues because it is the FCode that generates the TCX device node, and so you end up with the case where the DT node exists yet the underlying hardware isn't there and so things rapidly start to go downhill...
Is this driver installed on real hardware because OpenBIOS cannot run the FCode ROM of the card so this is used as a fallback instead? Or what is a valid ROM? With testing for QEMU instead of hardware presence wouldn't you get the same problem on real hardware: driver would be installed even without card present? (Of course OpenBIOS probably only works with QEMU and likely nobody uses it on real hardware so this is theoretical but testing for QEMU still does not look like the right thing to do here.) I can see two ways:
Right. I decided to do this for 2 reasons: firstly it would mean no change in behaviour for other projects that use OpenBIOS (e.g. temlib) and secondly during the transition then it would allow newer OpenBIOS binaries to be tested on older QEMU versions.
- If QEMU always supplies the driver as card ROM which will then be installed, when
is this fallback necessary at all? Wouldn't it be simpler to just remove it altogether? On QEMU it's not needed, other configs probably don't work anyway and if they worked you may get the same problem as in the QEMU case before this patch when card is missing so getting rid of this fallback would simplify code and may only break real hardware case which is likely already broken anyway.
or
- If you think fallback still makes sense and is used by some real case then the
correct test may be to check if TCX card is present or not, not if running on QEMU or not. Maybe you should do this when setting up the card during sbus scan. The drivers/sbus.c seems to create device nodes when some slots are occupied (? is this correct? are these cards hardwired to these slots or what if they are not in the expected slot or something else is there). Anyway, you could check if these nodes are existing but ROM is not valid to decide to install the driver fallback which seems more correct. Or you could try to fall back when mapping the ROM or interpreting it has failed.
And this patchset implements option 1 :)
But I think a proper fix for the problem would be to fix FCode ROM support instead of adding fallbacks for everything. This reminds me of the QEMU VGA ndrv fallback which is also installed for every VGA device regardless if it works with them or not and I had to disable it to try a card ROM or driver with the ati-vga device. Along the same lines, that fallback (and the fw_cfg hack to download the driver) could also be removed if QEMU set the card ROM to the ndrv but the problem with that is that this is the std vga device and we would need to patch ROM only when this is used in a ppc mac emulation for which there're no functions in QEMU yet. But changing QEMU to allow board code to specify card ROM may be cleaner than the current way of patching in the ndrv for all vga devices and that would allow removing a lot of hacks from OpenBIOS: the fw_cfg download, ndrv installation and vga-ndrv? switch and would make it simpler until proper FCode support could be implemented some time later.
I hope at least some of what I said makes sense.
Indeed, although this is a little off-topic since SBus used by SPARC is separate from PCI. Note that you can disable the VGA ndrv driver via -prom-env 'vga-ndrv?=false' on the command line if you need it for testing.
It is already possible to provide an option ROM to the VGA device in QEMU, the slightly tricky part is that you need to add some routines to QEMU to dynamically create the option ROM by creating a "dummy" option ROM header and then injecting the FCode payload. Then it should just be a case of mapping to ROM into the PCI device, applying a small patch to OpenBIOS and then you should be good.
ATB,
Mark.