sym vs ncr driver for emulated LSI 53C895A

From: Miroslav Lachman <000.fbsd_at_quip.cz>
Date: Thu, 09 Feb 2023 19:04:58 UTC
I have FreeBSD 12.4 virtual machine installed inside KVM. This machine 
has 2 disks. One is 30GB connected as VirtIO vtbd0. There is installed 
system. The second is 20TB iSCSI connected to KVM and should be 
available inside VM as SCSI disk da0 but it is not.

I see following errors in a log

sym0:1: message c sent on bad reselection.
sym0:1:control msgout: 80 6.
(probe1:sym0:0:1:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe1:sym0:0:1:0): CAM status: Command timeout
(probe1:sym0:0:1:0): Retrying command, 3 more tries remain
sym0:1: message c sent on bad reselection.
sym0:1:control msgout: 80 6.
(probe1:sym0:0:1:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe1:sym0:0:1:0): CAM status: Command timeout
(probe1:sym0:0:1:0): Retrying command, 2 more tries remain
sym0:1: message c sent on bad reselection.
sym0:1:control msgout: 80 6.
(probe1:sym0:0:1:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe1:sym0:0:1:0): CAM status: Command timeout
(probe1:sym0:0:1:0): Retrying command, 1 more tries remain
sym0:1: message c sent on bad reselection.
sym0:1:control msgout: 80 6.
(probe1:sym0:0:1:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe1:sym0:0:1:0): CAM status: Command timeout
(probe1:sym0:0:1:0): Retrying command, 0 more tries remain
sym0:1: message c sent on bad reselection.
sym0:1:control msgout: 80 6.
(probe1:sym0:0:1:0): INQUIRY. CDB: 12 00 00 00 24 00
(probe1:sym0:0:1:0): CAM status: Command timeout
(probe1:sym0:0:1:0): Error 5, Retries exhausted

Relevant part of the dmesg:

virtio_pci0: <VirtIO PCI Block adapter> port 0xc200-0xc27f mem 
0xfc0b7000-0xfc0b7fff,0xfebf8000-0xfebfbfff irq 10 at device 5.0 on pci0
vtblk0: <VirtIO Block Adapter> on virtio_pci0
vtblk0: 30720MB (62914560 512 byte sectors)
virtio_pci1: <VirtIO PCI Balloon adapter> port 0xc2c0-0xc2ff mem 
0xfebfc000-0xfebfffff irq 10 at device 6.0 on pci0
vtballoon0: <VirtIO Balloon Adapter> on virtio_pci1
sym0: <895a> port 0xc000-0xc0ff mem 
0xfc0b8000-0xfc0b83ff,0xfc0b2000-0xfc0b3fff irq 11 at device 7.0 on pci0
sym0: No NVRAM, ID 7, Fast-40, LVD, parity checking
sym1: <895a> port 0xc100-0xc1ff mem 
0xfc0b9000-0xfc0b93ff,0xfc0b4000-0xfc0b5fff irq 11 at device 8.0 on pci0
sym1: No NVRAM, ID 7, Fast-40, LVD, parity checking
ahci0: <Intel ICH9 AHCI SATA controller> port 0xc380-0xc39f mem 
0xfc0ba000-0xfc0bafff irq 10 at device 9.0 on pci0
ahci0: AHCI v1.00 with 6 1.5Gbps ports, Port Multiplier not supported
ahcich0: <AHCI channel> at channel 0 on ahci0
ahcich1: <AHCI channel> at channel 1 on ahci0
ahcich2: <AHCI channel> at channel 2 on ahci0
ahcich3: <AHCI channel> at channel 3 on ahci0
ahcich4: <AHCI channel> at channel 4 on ahci0
ahcich5: <AHCI channel> at channel 5 on ahci0
ahci1: <Intel ICH9 AHCI SATA controller> port 0xc3a0-0xc3bf mem 
0xfc0bb000-0xfc0bbfff irq 10 at device 10.0 on pci0
ahci1: AHCI v1.00 with 6 1.5Gbps ports, Port Multiplier not supported
ahcich6: <AHCI channel> at channel 0 on ahci1
ahcich7: <AHCI channel> at channel 1 on ahci1
ahcich8: <AHCI channel> at channel 2 on ahci1
ahcich9: <AHCI channel> at channel 3 on ahci1
ahcich10: <AHCI channel> at channel 4 on ahci1
ahcich11: <AHCI channel> at channel 5 on ahci1


The controller is listed by pciconf

# pciconf -lv | grep -A4 sym
sym0@pci0:0:7:0:        class=0x010000 card=0x10000000 chip=0x00121000 
rev=0x00 hdr=0x00
     vendor     = 'Broadcom / LSI'
     device     = '53c895a'
     class      = mass storage
     subclass   = SCSI
sym1@pci0:0:8:0:        class=0x010000 card=0x10000000 chip=0x00121000 
rev=0x00 hdr=0x00
     vendor     = 'Broadcom / LSI'
     device     = '53c895a'
     class      = mass storage
     subclass   = SCSI

I tried to search what should be the right driver for LSI 53c895a but I 
am a bit confused. sym(4) is attached on boot, but it is also listed on 
hardware notes and man page for ncr(4) driver

https://www.freebsd.org/releases/12.4R/hardware/

I tried to kldload ncr but can't load ncr: No such file or directory.

Should ncr be built separately? (the system is running 12.4 with GENERIC 
kernel)

And how can I configure it to use ncr instead of sym?
Or are there any other way to make FreeBSD guest happy in KVM host? (I 
am not controlling the KVM host, I don't know the exact configuration of it)

Kind regards
Miroslav Lachman